question

paparika avatar image
paparika asked ·

can not get profile when requesting both alexa:all + profile scopes at the same time

/*
my code has granted user auth for alexa successfully but can not get 
user profile even if 'profile' scope is added. I can also confirm that I can 
get profile separately without 'alexa:all' scope.
*/


private static final String[] APP_SCOPES = {"profile", "alexa:all"};

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");

if(mAuthManager != null){
    mAuthManager.authorize(APP_SCOPES, options, new AuthListener());
}

private class AuthListener implements AuthorizationListener {

    /**
     * Authorization was completed successfully.
     * Display the profile of the user who just completed authorization
     * @param response bundle containing authorization response. Not used.
     */
    @Override
    public void onSuccess(Bundle response) {

        final String authorizationCode = response.getString(AuthzConstants.BUNDLE_KEY.AUTHORIZATION_CODE.val);

        if(mAuthManager != null) {
            mAuthManager.getProfile(new APIListener(){
                @Override
                public void onSuccess(Bundle bundle) {
                    // Retrieve the data we need from the Bundle
                    Bundle profileBundle = bundle.getBundle(
                            AuthzConstants.BUNDLE_KEY.PROFILE.val);

			//profileBundle is always null !!
                }

                @Override
                public void onError(AuthError authError) {
                }
            });

        }
    }

    /**
     * There was an error during the attempt to authorize the application.
     * Log the error, and reset the profile text view.
     * @param ae the error that occurred during authorize
     */
    @Override
    public void onError(final AuthError ae) {

    }

    /**
     * Authorization was cancelled before it could be completed.
     * A toast is shown to the user, to confirm that the operation was cancelled, and the profile text view is reset.
     * @param cause bundle containing the cause of the cancellation. Not used.
     */
    @Override
    public void onCancel(Bundle cause) {

    }
}

alexa voice servicealexa
10 |2000 characters needed characters left characters exceeded

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

Eric@Amazon avatar image
Eric@Amazon answered ·
10 comments
10 |2000 characters needed characters left characters exceeded

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

but my security profile already appears in the form 'Login with Amazon Configurations'

0 Likes 0 ·

I found Consent Privacy Notice URL and Consent Logo Image is showing when I try to login with amazon to enable alexa, so this means my security profile is ok?

0 Likes 0 ·

I confirmed I can get user profile if APP_SCOPES is set just as {"profile"}

0 Likes 0 ·

I'm not sure if it is a bug, but if I request with scope {"profile"} first , then request with {"profile","alexa:all"}, I can get user profile as expected

0 Likes 0 ·

I'm sorry, I forgot to mention that. Since the alexa:all scope is designed as a device linking scope, it should be requested in a separate authorization request other than the profile scope (which gets account information).

0 Likes 0 ·

so you mean I have to request for them separately? but I'm confused what to do, apparently I don't want to popup the login dialog twice, right?

0 Likes 0 ·
Show more comments
paparika avatar image
paparika answered ·

but my security profile already appears in the form 'Login with Amazon Configurations'

1 comment
10 |2000 characters needed characters left characters exceeded

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

As per Amazon implementation, we get either AccessToken or Authorization code. In case of Authorization grant, we can't get user information

0 Likes 0 ·
newuser-396f49f8-7297-4c1e-9806-fd573a3dc7c7 avatar image
newuser-396f49f8-7297-4c1e-9806-fd573a3dc7c7 answered ·

1. https://developer.amazon.com/docs/alexa-voice-service/authorize-companion-site.html

2. "SCOPE":"alexa:all profile"

Reminder there is a space in between

3. Then use the token (with profile scope now) to call this API as below:

https://developer.amazon.com/docs/login-with-amazon/obtain-customer-profile.html

10 |2000 characters needed characters left characters exceeded

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