How to Authenticate with Alexa Voice Service from Android?

匿名 (未验证) 提交于 2019-12-03 01:20:02

问题:

I am trying to connect to Alexa Voice Service from and 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

回答1:

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)



回答2:

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.



回答3:

The APP_SCOPE should be "alexa:all"



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!