Obtaining new Access and Refresh Token in case of Device Authorization Grant with AWS Cognito

0

We are implementing the Device Authorization Grant with AWS Cognito using the information provided in this AWS Blog - Implement OAuth 2.0 device grant flow by using Amazon Cognito and AWS Lambda. Related to this setup, what is the way to get a new access token and refresh token using the current refresh token? What is the endpoint to which the request has to be sent? A sample request and response for this flow would be helpful.

Pradhan
gefragt vor einem Monat64 Aufrufe
2 Antworten
1
Akzeptierte Antwort

You need to send a POST request with your refresh token to the Cognito token endpoint.

ℹ️ In the previous link you will find some examples of requests and responses

profile picture
EXPERTE
beantwortet vor einem Monat
profile picture
EXPERTE
überprüft vor 5 Tagen
1

Thank you, @Osvaldo Marte.

Request:

curl --location 'https://{your-cognito-domain}.auth.{aws-region}.amazoncognito.com/oauth2/token' \
--header 'Authorization: Basic {Base64Encode(client_id:client_secret)}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=refresh_token' \
--data-urlencode 'refresh_token={your_refresh_token}'

The response will be:

{
    "id_token": "{id_token}",
    "access_token": "{access_token}",
    "expires_in": 3600,
    "token_type": "Bearer"
}
Pradhan
beantwortet vor einem Monat

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen