question

zzmehdi avatar image
zzmehdi asked

Alexa Access Token- ["alexa:all"] parameter for requestScopes

Hi all, I'm trying to get an access token for an iOS app in Swift. After creating Amazon login and ensuring it works, I added the methods to obtain an access token listed here. https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/docs/authorizing-your-alexa-enabled-mobile-app#Resources

Below you can see the methods for loginButtonTouched and checkIsUserSignedIn. Previously the code worked with the requestScope parameters as ["profile","postal_code"]. However, adding the requestScope parameter as ["alexa:all"] seems to result in a bug.

Instead of allowing a user to complete login once login button is touched and then returning to the app, the browser doesn't finish loading and returns to the app. Setting up breakpoints shows that after clicking login, and when the browser is in the midst of loading, it goes to the App Delegate and isValidRedirectSignInURL returns false. That's when the browser doesn't finish loading and returns to the app. Any help would be much appreciated! Thank you!

//method for tapping login button
@IBAction func loginButtonTouched(sender: UIButton) {
  let productId = "ABC123"
  let deviceSerialNumber = "123"

 let amazonAuthorizeUserDelegate = AMZNAuthorizeUserDelegate()

 let requestScopes = ["alexa:all"]

 var options = [String:AnyObject]()

 let scopeData = String(format:"{\"alexa:all\":{\"productID\":\"%@\", ", "\"productInstanceAttributes\":{\"deviceSerialNumber\":\"%@\"}}}", productId, deviceSerialNumber)

  options[kAIOptionScopeData] = scopeData

  AIMobileLib.authorizeUserForScopes(requestScopes, delegate:amazonAuthorizeUserDelegate, options: options)
//method for checking if user is signed in
func checkIsUserSignedIn() {
  let amazonGetAccessTokenDelegate = AMZNGetAccessTokenDelegate()

  let requestScopes = ["alexa:all"]

  AIMobileLib.getAccessTokenForScopes(requestScopes, withOverrideParams: nil, delegate: amazonGetAccessTokenDelegate)
alexa voice service
10 |5000

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

1 Answer

luandrecast avatar image
luandrecast answered

Hi @zzmehdi

Check out this Sample repo , hope it helps.

10 |5000

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