Alexa: How to test request for access token using refresh token?
Asked Answered
U

0

8

Trying to find the Signature and SignatureCertChainUrl headers within Amazon's POST request to renew the access token using the refresh token. I deliberately set the access token to expire in 3600 seconds:

var res = { 
    "access_token": access_token,
    "refresh_token": refresh_token,
    "expires_in": 3600,
    "token_type": "bearer",
    "state": state,
    "scope": myScope
}

then made a query to Alexa after the access token was supposed to expire. However, Amazon made no request to refresh the token as it should have done (to quote the docs, "Alexa also calls [the access] URI with the refresh token to get a new access token when the previous token expires").

How can I test my skill's response to getting a new access token with the refresh token?

Ulani answered 20/8, 2018 at 18:20 Comment(6)
If you have configured Oauth2 properly you don't have to worry about refresh token. Alexa will include access token in very request after the account is linked. And if access token expires, Alexa will refresh it and get you a valid one.Alidis
I'm aware of that, but Alexa will be making the request for a new access token to my authentication server, and I want to be sure that I handle that request properly. Thus, I would like an example of how it comes in, or a way for me to make Alexa send that request.Ulani
After a token expires that is 3600 seconds in your case. Trigger an intent of the skill. This way alexa will have to refresh the token before sending you the new token along with the request to your skills backend codeAlidis
I've tried that using the Alexa Developer Console, but the logs on my server indicate that no request was made, even after the token expired in 3600 seconds. I would make requests after the 6 minutes passed and Alexa would still respond with only knowledge it could have by making a query using the access tokenUlani
To clarify, the access token that Alexa has won't actually expire in 6 minutes (it will actually take a couple days for it to expire), but for testing purposes, I assumed that telling Alexa that it expired sooner would trigger it to make the request using the refresh token. However, that so far has not been the caseUlani
Check your access_type, set the value to offline if your application needs to refresh access tokens when the user is not present at the browser.Alidis

© 2022 - 2024 — McMap. All rights reserved.