Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 获取Alexa配置文件信息_Android_Alexa_Alexa Voice Service - Fatal编程技术网

Android 获取Alexa配置文件信息

Android 获取Alexa配置文件信息,android,alexa,alexa-voice-service,Android,Alexa,Alexa Voice Service,我正在使用下面的代码授权Alexa android应用程序。 如何从下面的代码中获取配置文件信息 private static final String[] APP_SCOPES= {"alexa:all"}; String PRODUCT_DSN = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID); Bundle option

我正在使用下面的代码授权Alexa android应用程序。 如何从下面的代码中获取配置文件信息

private static final String[] APP_SCOPES= {"alexa:all"};
String PRODUCT_DSN = Settings.Secure.getString(mContext.getContentResolver(),
                Settings.Secure.ANDROID_ID);
        Bundle options = new Bundle();
        String scope_data = "{\"alexa:all\":{\"productID\":\"" + mProductId +
                "\", \"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, getCodeChallenge());
        options.putString(AuthzConstants.BUNDLE_KEY.CODE_CHALLENGE_METHOD.val, "S256");
        options.putBoolean(AuthzConstants.BUNDLE_KEY.PROFILE.val, true);

        mAuthManager.authorize(APP_SCOPES, options, authListener);

最后我找到了答案,需要获取访问令牌,然后调用api:


标题:授权”,无记名 访问令牌

例如:

String url = "https://api.amazon.com/user/profile";
OkHttpClient client = ClientUtil.getTLS12OkHttpClient();

Request request = new Request.Builder()
        .url(url)
        .addHeader("Authorization", "Bearer " + access_token)
        .build();

client.newCall(request).enqueue(new Callback() {
    @Override
    public void onFailure(Call call, final IOException e) {

    }

    @Override
    public void onResponse(Call call, Response response) throws IOException {
        String s = response.body().string();




    }
});