如何通过Android的Alexa语音服务进行身份验证?

the*_*osh 5 android amazon

我正在尝试按照此页面上的说明从和Android应用程序连接到Alexa语音服务。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());
Run Code Online (Sandbox Code Playgroud)

首先,我不知道应该使用APP_SCOPES。我将其设置为:

protected static final String[] APP_SCOPE = new String[]{"profile", "postal_code"};
Run Code Online (Sandbox Code Playgroud)

但我从服务器收到错误

AuthError cat= INTERNAL type=ERROR_SERVER_REPSONSE - com.amazon.identity.auth.device.AuthError: Error=invalid_scope error_description=An unknown scope was requested
Run Code Online (Sandbox Code Playgroud)

TyM*_*arc 3

APP_SCOPE是 “alexa:all”

PRODUCT_DSN可以是您想要的任何内容,根据 Joshua Frank 的建议“1234” https://forums.developer.amazon.com/forums/message.jspa?messageID=18973#18973

PRODUCT_ID是AVS 开发者门户 ( https://developer.amazon.com/edw/home.html#/avs/list )中的 ID

应用程序安全配置文件中的 CODE_CHALLENGE 客户端密钥(应已在 S256 中进行哈希处理