question

Sharvin Shah avatar image
Sharvin Shah asked

Client authentication failed in request for Amazon Alexa Smart Home skill

I am referring to Amazon documentation for the purpose of Customer Authentication. Currently, I am using LWA.

Steps I followed:

  1. I enabled the Send Alexa Events Permission from the Alexa developer Console in Build > Permission page.
  2. I took the grant code from the request in the cloudwatch logs which was sent when I logged in using Alexa companion app.

Example:-

   {
     "directive": {
         "header": {
             "messageId": "Example",
             "name": "AcceptGrant",
             "namespace": "Alexa.Authorization",
             "payloadVersion": "3"
         },
         "payload": {
            "grant": {
                "code": "Example2",
                "type": "OAuth2.AuthorizationCode"
            },
            "grantee": {
                "token": "Example3",
                "type": "BearerToken"
            }
         }
      }
    }
  1. Permission Page under build on Alexa Developer console gave me client-Id and client-secret Which I used for making the post request to https://api.amazon.com/auth/o2/token.

Example:-

POST /auth/o2/token HTTP/l.l
 Host: api.amazon.com
 Content-Type: application/x-www-form-urlencoded;charset=UTF-8 
 grant_type=authorization_code&code=&client_id=&client_secret=

I passed the code,client_id, and client_secret in the above example and made the post request to this URL https://api.amazon.com/auth/o2/token

  1. I tried using x-www-form-urlencoded;charset=UTF-8 and also JSON for the Content-Type.

I followed the step given in the above documentation and I am stuck on the error ( 401 Unauthorized ):

{
    "error_description": "Client authentication failed",
    "error": "invalid_client"
}

I tried implementing it using Python code and Postman both. Ending up with the Same above error scenario.

alexa skills kitalexaalexa smart homeamazon web services
2 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I am facing the same issue! Have you solved this issue? If you have solved then please help me.

0 Likes 0 ·

Sorry for the late reply, but if you're still facing the issue please create a new post as this is a slightly older post.

-1 Like -1 ·

1 Answer

Jason@Amazon avatar image
Jason@Amazon answered

Using Inherit auth from parent and Content-Type with application/x-www-form-urlencoded should be enough for headers. Other than that, it's possible that the code that you grabbed has expired - try disabling and reenabling the skill with account linking to grab the new code and test with that.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.