5

I am trying to connect to Alexa Voice Service from an Android app following the directions on this page: https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/docs/authorizing-your-alexa-enabled-product-from-an-android-or-ios-mobile-app

Bundle options = new Bundle();
String scope_data = "{\"alexa:all\":{\"productID\":\"" + PRODUCT_ID +
                    "\", \"productInstanceAttributes\":           {\"deviceSerialNumber\":\"" + PRODUCT_DSN + "\"}}}";
options.putString(AuthzConstants.BUNDLE_KEY.SCOPE_DATA.val, scope_data);
options.putBoolean(AuthzConstants.BUNDLE_KEY.GET_AUTH_CODE.val, true);
options.putString(AuthzConstants.BUNDLE_KEY.CODE_CHALLENGE.val, CODE_CHALLENGE);
options.putString(AuthzConstants.BUNDLE_KEY.CODE_CHALLENGE_METHOD.val, "S256");
mAuthManager.authorize(APP_SCOPES, options, new AuthorizeListener());

First, I don't know what APP_SCOPES should be. I set it to:

protected static final String[] APP_SCOPE = new String[]{"profile", "postal_code"};

but I get an error from the server

AuthError cat= INTERNAL type=ERROR_SERVER_REPSONSE - com.amazon.identity.auth.device.AuthError: Error=invalid_scope error_description=An unknown scope was requested

What am I doing wrong and how can I do this right?

starball
  • 20,030
  • 7
  • 43
  • 238
theJosh
  • 2,894
  • 1
  • 28
  • 50

3 Answers3

3

The APP_SCOPE is : "alexa:all"

The PRODUCT_DSN can be anything you want, "1234" as per suggestion from Joshua Frank (https://forums.developer.amazon.com/forums/message.jspa?messageID=18973#18973)

The PRODUCT_ID is the ID in the AVS Developper Portal (https://developer.amazon.com/edw/home.html#/avs/list)

The CODE_CHALLENGE the Client Secret in the Security Profile of your application (should be already hashed in S256)

TyMarc
  • 932
  • 7
  • 13
  • The instructions make it sound like you need to generate your own code challenge. That was one of my issues. – theJosh Aug 06 '15 at 19:10
  • The documentation is not really clear... well, it's **beta** – TyMarc Aug 06 '15 at 20:25
  • I agree with you on APP_SCOPE and PRODUCT_DSN. I just don't get it on PRODUCT_ID and CODE_CHALLENGE. Why do you take the PRODUCT ID from AVS Developer Portal while the documents https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/docs/authorizing-your-alexa-enabled-product-from-an-android-or-ios-mobile-app and http://login.amazon.com/ios#install_login_with_amazon_library only mention about App Console: http://login.amazon.com/manageApps ? And CODE_CHALLENGE is described at the top of my first link, why do you say it's taken from the Client Secret in Security Profile? – quanguyen Oct 29 '15 at 04:56
  • That might not be true anymore, the answer was given when AVS was still in beta. If the answer is not good anymore and you have a better answer, please go ahead, it might help someone else too! – TyMarc Oct 29 '15 at 15:40
0

The problem is not with the APP_SCOPES variable, it is actually with the PRODUCT_ID, PRODUCT_DSN variables passed in the scope data.

I faced this exact same issue and have raised a query in amazon developers forum on what needs to be passed in those variables - Alexa authentication issue using beta SDK

Once the PRODUCT_ID, PRODUCT_DSN & CODE_CHALLENGE variables are determined then the authentication should be pretty much straight forward.

Vikram Ezhil
  • 995
  • 1
  • 9
  • 15
0

The APP_SCOPE should be "alexa:all"

theJosh
  • 2,894
  • 1
  • 28
  • 50