且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何以编程方式交换授权代码以使用python从cognito获取访问令牌

更新时间:2023-02-12 19:23:56

Finlay可以通过以下代码交换授权代码,以从cognito auth中检索access_token,刷新和id_token:

Finlay got the way to exchange Authorization code to retrieve the access_token along with the refresh and id_token from cognito auth with below code:

response = requests.post(url + '/oauth2/token',{'Content-Type':'application/x-www-form-urlencoded', 'grant_type': grant_type, 'client_id': App_client_id,  'code': code, 'redirect_uri': 'http://localhost:5000/login'})
print(response.json())

谢谢