Error Using the Access Token to Make Alexa Voice Service API Calls
Hello, I have a problem using AVS API. We have error 400 when trying to get access token. The error message is "Access service cannot process the given type". When i read the documentation, the cause is "The content type for the request was not valid", but I check the refresh token, client_id, client_secret, and it was the correct values. Here, the API to get Access Token to Make Alexa Voice Service API Calls : POST /auth/o2/token HTTP/1.1 Host:
api.amazon.com Content-Type: application/x-www-form-urlencoded Cache-Control: no-cache grant_type=refresh_token&refresh_token=Atzr%7CIQEBLzAtAhUAibmh-1N0E&client_id=amzn1.application-oa2-client.b91a4d2fd2f6&client_secret=6963038c1c2063c33ab9eedc0cf822 Did i miss something or the error comes from amazon ? Thanks.
Hi hichamt, I see a couple of things with this request. 1) If you are really trying to get an access token when you have an expired access token then the post request that you have shown does not contain the correct information. Please see the documentation here: (
https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/docs/authorizing-your-alexa-enabled-product-from-an-android-or-ios-mobile-app) With a refresh_token grant token you should be sending the following: send the following parameters: -> grant_type: refresh_token -> refresh_token: The refresh token. -> client_id: Call getClientId() The client secret is not required. 2) The refresh tokens looks malformed to me (it should be much longer). Can you expand on how you retrieved it?
Hello, Thanks for your reply. Regarding the second point, i didn't put the correct one :) . And about the first one, i send the correct parametres according to the documentation except the client_secret which you told me that it's not required. I try without client_secret but have same error. Here is the link of documentation to get the refresh token and access token :
https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/docs/authorizing-your-alexa-enabled-product-from-a-website 1) To retrieve the access token and refresh token, we use the Authorisation Code grant. Here is the request found in the doc. These are fake values : POST /auth/o2/token HTTP/1.1 Host:
api.amazon.com Content-Type: application/x-www-form-urlencoded Cache-Control: no-cache grant_type=authorization_code&code=ANBzsjhYZmNCTeAszagk&client_id=amzn1.application-oa2-client.b91a4d2fd2f64&client_secret=6963038c1c2063c33ab9eedc0cf8&redirect_uri=https%3A%2F%2Flocalhost 2) To get an access token when we have an expired access token, we use the refresh token grant type. In my first post, i show how we do it according to the doc in the same link. Thanks Again. Message was edited by: hichamt