Invalid Grant Parameter
See original GitHub issueWhen I run the code:
CLIENT_ID="amzn1.application-oa2-client.2ce85ab0db2d4e9..."
CLIENT_SECRET="4247e7121f974bd0dc964d99e3dfa445b8572e..."
CODE="ANudVcrBPTyYrgKMHhtu"
GRANT_TYPE="authorization_code"
REDIRECT_URI="https://localhost:9745/authresponse"
curl -X POST --data "grant_type=${GRANT_TYPE}&code=${CODE}&client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&redirect_uri=${REDIRECT_URI}" https://api.amazon.com/auth/o2/token
i get the following error:
{"error_description":"The request has an invalid grant parameter : code","error":"invalid_grant"}
can anyone help me?
Issue Analytics
- State:
- Created 6 years ago
- Comments:18 (5 by maintainers)
Top Results From Across the Web
The request has an invalid grant parameter : refresh_token ...
The spapi oauth code which is used to generate the refresh token is a short lived token valid only for 5 minutes. This...
Read more >"invalid_grant" error when requesting an OAuth Token
Issue symptoms. When I attempt to obtain an access token, I receive the error below. {"error":"invalid_grant",
Read more >question - Amazon Developer Forums - AnswerHub
Invalid grant parameter : refresh_token for api.amazonalexa.com/v2 query · Request Type: POST · data: { · 'refresh_token': 'Atza|IwEBIF5...', # Same ...
Read more >Google OAuth “invalid_grant” nightmare — and how to fix it
A token that hasn't been used for 6 months automatically expires. As many of our users that got the “invalid_grant” error was created...
Read more >How to get an access token with Auth Code Grant | DocuSign
This topic demonstrates how to manually generate an access token using Authorization Code Grant authentication or with a refresh token.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just to document my process somewhat…
The Amazon UI has changed a fair bit when creating the ‘device’. But it’s easy enough to muddle through that part. I used this page: https://sakirtemel.github.io/MMM-alexa/ to generate the ‘Code’. You need to add https://sakirtemel.github.io/MMM-alexa/ to the list of Redirect URLs for your device in the AVS product.
Once I had the ‘Code’ I used a REST console in Chrome (https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo)
The url: https://api.amazon.com/auth/o2/token Select POST, Data Form then add your parameters for: client_id client_secret code grant_type redirect_uri
I discovered two things at this point.
From that I got the refresh_token.
I have to say, I’ve not got it working properly yet - but I haven’t had time to debug what’s going on (could be mic issue etc). So let me know if anyone does all this and gets it to work!
In case anyone comes across this. I managed to get it working. One thing to note is that the ‘code’ you receive from Amazon expires when you try to use it, whether you receive back an access token or not. Also, the redirect_uri must be the same as the one you used to grant the initial code.