MMM-awesome-alexa: Invalid Grant Parameter
When 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?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (5 by maintainers)
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.
Are there any updates on an easier way to get the refresh code? I am still having issues
I’m still having issues getting the access code, I’ve tried all 3 ways listed and nothing works, I managed to get the initial code from https://sakirtemel.github.io/MMM-alexa/ but when i used ARC to post a request I got 404 not found - <UnknownOperationException/>, When using the token from the URLmethod it;s difficult to decipher the token it seems massive compared to the one in the example. Any help would be much appreciated
Is there an actual ‘HOW TO GET THIS TO WORK’ guide anywhere? There is so much information and misinformation here that it’s VERY hard to tell what works and what doesn’t… Lots of problems to get a module to work…