question

Gilles van den Hoven avatar image
Gilles van den Hoven asked

Smart home account link error (debug followed)

Skill ID: amzn1.ask.skill.f1cb0f2a-9545-414e-8a02-2112895c82de

Followed steps here: https://forums.developer.amazon.com/articles/38610/alexa-debugging-account-linking.html

I have my own custom oauth2 endpoint.

  1. From amazon -> my.domain.com/oauth/link -> Saves Amazon redirect_uri and State parameter and fwds to Google signin.
  2. Google goes back to my.domain.com/oauth/redirect where i send the token from google to Amazon redirect_uri, including state.
  3. Amazon contacts my.domain.com/oauth/token for a token Above steps are working for custom skill, but fail for smart home skill.

note: since the client_id, client_secret and scope which i send to Google are being sent from my own domain i have dummy values at my skill since they get overwritten anyway.

Step 1 - From Amazon towards my.domain.com/oauth2/link

array (
  'client_id' => '...',
  'response_type' => 'code',
  'state' => '...',
  'scope' => '...',
  'redirect_uri' => 'https://pitangui.amazon.com/api/skill/link/MZLGLRJF8IFP2',
)

Then i save the state and redirect_uri in a session and redirect to Google.

Step 2 - From Google back to my.domain.com/oauth2/redirect

array (
  'code' => '...'
)

I redirect back to the redirect_uri from the original request, appending state and code.

Step 3 - From Amazon to my.domain.com/oauth2/token

array (
  'grant_type' => 'authorization_code',
  'code' => '...',
  'redirect_uri' => 'https://pitangui.amazon.com/api/skill/link/MZLGLRJF8IFP2',
  'client_id' => '...',
)

Step 3.1 - From my.domain.com/oauth2/token towards Google to exchange the code for an access_token and refresh_token

array (
  'grant_type' => 'authorization_code',
  'client_id' => '...',
  'client_secret' => '...',
  'code' => '...',
  'redirect_uri' => '...',
)

Step 3.2 - Do magic towards Google

I get a correct response from Google and send this back to Amazon.

headers returned:

http_response_header(200);
header('content-type: application/json');
header('cache-control: no-store');
header('pragma: no-cache');

body returned:

{"access_token":"...","token_type":"bearer","expires_in":3600,"refresh_token":"..."}

Result:

An error occurred while attempting to link Alexa with <skillName>. Please try again later.

Any tips? I have 2 observations:

  1. This exact same flow works for my (other) custom skill.
  2. I am conforming towards the oAuth2 response.
skillalexa smart homeaccount linkingredirect
10 |5000

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

0 Answers