question

sorin penteleiciuc avatar image
sorin penteleiciuc asked

"Invalid account linking credentials" integration with Azure B2C.

I am following this documentation https://developer.amazon.com/en-US/docs/alexa/account-linking/app-to-app-account-linking-starting-from-your-app.html in order to make an in app linking.


screenshot-2021-11-18-at-101709.jpg

I am blocked on the last step where I would like to do the skill enablement.

{
  
     
    "stage": "development",
    "accountLinkRequest": {
  
          
              "redirectUri": "https://mytenant.b2clogin.com/mytenant.onmicrosoft.com/B2C_1_susi/oauth2/v2.0/token?client_id=XXXXXXXXXXX&grant_type=authorization_code&scope=https://mytenant.onmicrosoft.com/b2capi/offline_access",        
              "authCode": "AUTHORIZATION CODE FROM B2C",         
               "type": "AUTH_CODE"    
              }
}

I am not sure what to put in redirectUri ?Is this a POST / GET ? Whos credentials are actually invalid ?

The redirect_uri parameter that was included in the authorization request to your OAuth 2.0 server to obtain the user's authorization code. This enables Amazon to retrieve access tokens from your token server. This URL must be opaque to Amazon.


Should be a link where Alexa can take tokens using the authorization code ?

https://docs.microsoft.com/en-us/azure/active-directory-b2c/authorization-code-flow#2-get-an-access-token
I am stuck because I get 400 "Invalid account linking credentials".

screenshot-2021-11-18-at-102103.jpg


This are the requests to get the Alexa Code:


String alexaAppURL =

https://alexa.amazon.com/spa/skill-account-linking-consent?

fragment=skill-account-linking-consent&

client_id=ALEXA_CLIENT_ID&

scope=alexa::skills:account_linking&

skill_stage=development&

response_type=code&

redirect_uri=https://pasdasdasda/redirect&state=LinkingAuthCode

String fallbackURL = https://www.amazon.com/ap/oa?

client_id=ALEXA_CLIENT_ID&

scope=alexa::skills:account_linking&

response_type=code&

redirect_uri=https://pasdasdasda/redirect&

state=LinkingAuthCode


Then I get the Alexa token:

curl --location --request POST ' https://api.amazon.com/auth/o2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'code=ANaGAwMnorKBqFFTgLIH' \-
-data-urlencode 'redirect_uri=https://pasdasdasda/redirect'
\--data-urlencode 'client_id=amzn1.application-oa2-client.ecXXXXXXXXXXX'
\--data-urlencode 'client_secret=d19d2XXXXXXXXXXXX' \
skillaccount linkingcustom skillskill-activation
10 |5000 characters needed characters left characters exceeded

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

0 Answers