title: Client authentication failed in Postman request for Amazon Alexa Smart Home Skill LWA
body: <p>I am referring to <a href="https://developer.amazon.com/docs/smarthome/authenticate-a-customer-permissions.html#enable-testing-for-the-skill" rel="nofollow noreferrer">Amazon documentation</a> for the purpose of Customer Authentication. Currently, I am using LWA.</p>
  
  <p>Steps I followed:</p>
  
  <ol>
  <li><p>I enabled the Send Alexa Events Permission from the Alexa developer Console in Build > Permission page.</p></li>
  <li><p>I took the grant code from the request in the cloudwatch logs which was sent when I logged in using Alexa companion app.</p></li>
  </ol>
  
  <p>Example:-</p>
  
  <pre><code>    {
       "directive": {
           "header": {
               "messageId": "Example",
               "name": "AcceptGrant",
               "namespace": "Alexa.Authorization",
               "payloadVersion": "3"
           },
           "payload": {
              "grant": {
                  "code": "Example2",
                  "type": "OAuth2.AuthorizationCode"
              },
              "grantee": {
                  "token": "Example3",
                  "type": "BearerToken"
              }
           }
        }
      }
  </code></pre>
  
  <ol start="3">
  <li>Permission Page under build on Alexa Developer console gave me client-Id and client-secret Which I used for making the post request to <a href="https://api.amazon.com/auth/o2/token" rel="nofollow noreferrer">https://api.amazon.com/auth/o2/token</a>.</li>
  </ol>
  
  <p>Example:-</p>
  
  <pre><code> 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&amp;code=&amp;client_id=&amp;client_secret=
  </code></pre>
  
  <p>I passed the code,client_id, and client_secret in the above example and made the post request to this URL <a href="https://api.amazon.com/auth/o2/token" rel="nofollow noreferrer">https://api.amazon.com/auth/o2/token</a></p>
  
  <ol start="4">
  <li>I tried using x-www-form-urlencoded;charset=UTF-8 and also JSON for the Content-Type.</li>
  </ol>
  
  <p>I followed the step given in the above documentation and I am stuck on the error ( 401 Unauthorized ):</p>
  
  <pre><code>{
      "error_description": "The request has an invalid grant parameter : code",
      "error": "invalid_grant"
  }
  </code></pre>
  
  <p>I tried implementing it using Python code and Postman both. Ending up with the Same above error scenario.</p>