Step 3: Configure Redirect URLs to Your App


In this step, you configure your skill to use app-to-app account linking and define the redirect URLs. You can use the Alexa developer console, Alexa Skills Kit Command Line Interface (ASK CLI), or the Account Linking Management REST API to configure your skill. During this step, you specify your app's redirect URL (deep-link enabled), access token URL, and more. For details, see URIs and endpoints.

In this topic, the terms URI and URL are used interchangeably.

Configure URLs in the Alexa developer console

To enable app-to-app account linking using the developer console, take the following steps.

  1. Sign in to the Alexa Skills Kit developer console.
  2. On the Skills tab, under SKILL NAME, scroll to find your skill.
  3. Under ACTIONS, expand the dropdown list in your skill's row, and then select Edit.
  4. On the left side, click TOOLS, and then click ACCOUNT LINKING.
  5. Turn on Allow users to link their account to your skill from within your application or website.
  6. For the authorization grant type, select Auth Code Grant.
    App-to-app account linking supports authorization code grant only.
  7. For Your Redirect URLs, add the redirect URLs described in URLs and endpoints / Your app's redirect URLs. Alexa and LWA use these URLs to send the user back to your app.
  8. For the other settings, use the settings described in Configure Account Linking.

Make sure that you follow these requirements when you add the redirect URLs:

  • The redirect URLs must comply with the specified URI syntax. The Alexa app opens this Universal Link or App Link URL to launch your app.
  • To handle different scenarios, you can add more than one redirect URL.
  • If your app doesn't support Universal Links or App Links, you should have a valid web page that your redirect URLs lead to. The web page should support the same process to receive the user's Amazon authorization code described in How it works.
  • Remember to add Your Redirect URLs for your iOS app, Android app, and website.

Configure URLs with the CLI

To enable app-to-app account linking using the ASK CLI, use the update-account-linking-info.

The following example shows the JSON format for the account-linking-request option. Set the redirectUrls to your fallback URL and the authorizationUrlsByPlatformto your iOS and Android redirect URLs. For more details about the fields, see Request body properties for Update account linking information REST API.

{
    "accountLinkingRequest": {
        "type": "AUTH_CODE",
        "authorizationUrl": "https://www.amazon.com/ap/oa/",
        "clientId": "your.skill.client.id.1",
        "scopes": [
            "user_id"
        ],
        "accessTokenUrl": "https://api.amazon.com/auth/o2/token",
        "accessTokenScheme": "HTTP_BASIC",
        "defaultTokenExpirationInSeconds": 20,
        "redirectUrls": ["https://www.example.com/ios_redirect", "https://www.example.com/android_redirect"],
        "authorizationUrlsByPlatform": [{
                "platformType": "iOS",
                "platformAuthorizationUrl": "https://your.ios.redirect_url"
            },
            {
                "platformType": "Android",
                "platformAuthorizationUrl": "https://your.android.redirect_url"
            }
        ],
        "skipOnEnablement": true,
        "voiceForwardAccountLinking": "ENABLED"
    }
}

Configure URLs with the REST API

To enable app-to-app account linking by using the Account Linking Management REST API, use the following settings for the accountLinkingRequest structure.

Field Description Type

skipOnEnablement

Set to true to let users enable the skill without starting the account linking flow. Set to false to require the normal account linking flow when users enable the skill. For more details, see Let Users Enable Your Skill without Account Linking.

Boolean

type

Specifies the OAuth authorization grant type. For app-to-app account linking, you must use AUTH_CODE.

String

authorizationUrl

Alexa app URL. For more details, see URLs and endpoints.

String

domains

List of additional domains that your log-in page gets content from. You can specify up to 15 domains.

Array of String

clientId

Identifier that the Amazon log-in page uses to recognize that the request came from your skill.

String

scopes

Strings that indicate the access that you need for the user account, such as the user_id. For smart home skills, this field is a required property. You can specify up to 15 scopes. You must include alexa::skills:account_linking.

Array of String

accessTokenUrl

Amazon OAuth URI for requesting authorization tokens

String

accessTokenScheme

Type of authentication used. Set to HTTP_BASIC or REQUEST_BODY_CREDENTIALS.

String

redirectUrls

List of fallback website URLs when your app links aren't available. For more details, see URLs and endpoints.

Array of String

authorizationUrlsByPlatform

List of URLs by mobile platform used to redirect back to your app. For more details, see URLs and endpoints.

Array of String

pkceConfiguration

Defines the Proof Key for Code Exchange (PKCE) parameters. Include if your app backend supports PKCE using SHA-256.

The pkceConfiguration object contains two properties:

  • status – Indicates whether the app backend supports PKCE.
    Valid values: ENABLED, DISABLED. Default: DISABLED.
  • codeChallengeMethod – Method used to create a code challenge. Account linking supports SHA-256.
    Valid value: S256.

Object

The following is an example of a request to add redirect URLs by using the Update account linking information operation.

{
   "accountLinkingRequest": {
      "accessTokenScheme": "HTTP_BASIC",
      "accessTokenUrl": "https://api.amazon.com/auth/o2/token/",
      "authorizationUrl": "https://www.amazon.com/ap/oa/",
      "clientId": "your.skill.client.id.1",
      "domains": [],
      "redirectUrls": ["yourRedirectURL1","yourRedirectURL2"],
      "scopes": ["user_id", "alexa::skills:account_linking"],
      "skipOnEnablement": true,
      "type": "AUTH_CODE",
      "pkceConfiguration": {
            "status": "ENABLED",
            "codeChallengeMethod": "S256"
      }
    }
}

Was this page helpful?

Last updated: frontmatter-missing