Cognito User Pool: How to refresh Access Token using Refresh Token

前端 未结 7 1444
星月不相逢
星月不相逢 2020-12-12 23:23

I am using Cognito user pool to authenticate users in my system. A successful authentication gives an ID Token (JWT), Access Token (JWT) and a Refresh

7条回答
  •  遥遥无期
    2020-12-13 00:10

    If you have a refresh token then you can get new access, id, and refresh token by just making this simple POST request to cognito:

    POST https://mydomain.auth.us-east-1.amazoncognito.com/oauth2/token >
    Content-Type='application/x-www-form-urlencoded'
    Authorization=Basic aSdxd892iujendek328uedj
    
    grant_type=refresh_token&
    client_id=djc98u3jiedmi283eu928&
    refresh_token=REFRESH_TOKEN
    

    You will get the following response back:

    HTTP/1.1 200 OK
    Content-Type: application/json
    
    {
       "access_token":"eyJz9sdfsdfsdfsd", 
       "refresh_token":"dn43ud8uj32nk2je",
       "id_token":"dmcxd329ujdmkemkd349r",
       "token_type":"Bearer", 
       "expires_in":3600
    }
    

提交回复
热议问题