Enable Deep Linking
Step 4: Redirect the User to the Alexa App
After the user accepts or denies the account linking request in your app, redirect them to back the Alexa app to finish the account linking process. For authorization code grants, use the Authorization Response. For implicit grants, use the Access Token Response. The full response URI must follow the OAuth 2.0 specification.
Send the authorization response
Follow these steps to redirect the user back to the Alexa app.
To redirect the user back to the Alexa app
- Construct the response by using the Alexa app redirect URI that the Alexa service provided in the authorization request.
- Append the query parameters defined by the specification to the Alexa app redirect URI.
- Open the redirect URI. The provided Alexa app redirect URI is a Universal Link or App Link that sends the user to the Alexa app when opened.
source=app to your authorization response.Success response
The following example shows a successful authorization response URI for an authorization code grant. The authorization response parameters are query parameters.
https://alexaAppRedirectUri?
code=yourServiceCode&
state=authorizationRequestState&
source=app
The following example shows a successful access token response URI for an implicit grant. The access token response parameters are fragment parameters.
https://alexaAppRedirectUri#
access_token=yourServiceToken&
token_type=Bearer&
expires_in=3600&
state=authorizationRequestState&
source=app
Error response
If the user denies the request or there's an error obtaining the grant, you must redirect the user back to the Alexa app with the appropriate OAuth2 error response.
The following example shows an error response URI for an authorization code grant.
https://alexaAppRedirectUri?
error=access_denied&
state=authorizationRequestState&
error_description=The%20user%20denied%20the%20request.
The following example shows an error response URI for an implicit grant.
https://alexaAppRedirectUri#
error=access_denied&
state=authorizationRequestState&
error_description=The%20user%20denied%20the%20request.
iOS example
The following example shows how to redirect the user back to the Alexa app by using the UIApplication.shared.open Swift library after you construct the response URI.
private func openUrl(alexaAppUrl: URL) {
UIApplication.shared.open(alexaAppUrl)
}
Android example
The following example shows how to redirect the user back to the Alexa app by using the Android Intent.ACTION_VIEW after you construct the response URI.
private fun openUrl(alexaAppUrl: String) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(alexaAppUrl))
startActivity(intent)
}
Last updated: frontmatter-missing