Glassware auth: android.accounts.OperationCanceledException "Sharing credentials is not allowed: canceling."
Asked Answered
O

1

8

We're trying to implement GDK glassware auth; have uploaded our beta APK to the Google Glass team and successfully implemented our MyGlass login page. We are now attempting to access the token via the steps listed here: https://developers.google.com/glass/develop/gdk/authentication#retrieving_accounts_on_glass

However the last step, String token = future.getResult().getString(AccountManager.KEY_AUTHTOKEN); is resulting in the following exception:

09-22 18:07:24.126: I/AccountManagerService(519): Sharing credentials is not allowed: canceling.
09-22 18:07:24.313: W/System.err(5822): android.accounts.OperationCanceledException
09-22 18:07:24.313: W/System.err(5822):     at android.accounts.AccountManager$AmsTask.internalGetResult(AccountManager.java:1503)
09-22 18:07:24.313: W/System.err(5822):     at android.accounts.AccountManager$AmsTask.getResult(AccountManager.java:1531)
09-22 18:07:24.313: W/System.err(5822):     at android.accounts.AccountManager$AmsTask.getResult(AccountManager.java:1452)
09-22 18:07:24.313: W/System.err(5822):     at com.mycom.app.MainActivity$5.run(MainActivity.java:234)
09-22 18:07:24.313: W/System.err(5822):     at android.accounts.AccountManager$11.run(AccountManager.java:1427)
09-22 18:07:24.313: W/System.err(5822):     at android.os.Handler.handleCallback(Handler.java:733)
09-22 18:07:24.313: W/System.err(5822):     at android.os.Handler.dispatchMessage(Handler.java:95)
09-22 18:07:24.313: W/System.err(5822):     at android.os.Looper.loop(Looper.java:149)
09-22 18:07:24.313: W/System.err(5822):     at android.app.ActivityThread.main(ActivityThread.java:5061)
09-22 18:07:24.313: W/System.err(5822):     at java.lang.reflect.Method.invokeNative(Native Method)
09-22 18:07:24.313: W/System.err(5822):     at java.lang.reflect.Method.invoke(Method.java:515)
09-22 18:07:24.313: W/System.err(5822):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-22 18:07:24.313: W/System.err(5822):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
09-22 18:07:24.313: W/System.err(5822):     at dalvik.system.NativeStart.main(Native Method)

The request we are trying to push via Mirror API is formed like this (and returns an OK status code):

POST https://www.googleapis.com/mirror/v1/accounts/google_user_token/com.ourcom.app.session/ourapp_username

BODY 
{"authTokens":[{"type":"com.ourcom.app.session","authToken":"****************"}]}

HEADERS
{"Authorization":"Bearer ya29.iAAf********","Content-Type":"application/json;charset=utf-8"}

And this is our local Glass code:

AccountManager accountManager = AccountManager.get(this);
// Use your Glassware's account type.
Account[] accounts = accountManager.getAccountsByType("com.ourcom.app.session");

// Your auth token type.
final String AUTH_TOKEN_TYPE = "com.ourcom.app.session";

if (accounts.length > 0) {

    accountManager.getAuthToken(accounts[0], AUTH_TOKEN_TYPE, null, this, new AccountManagerCallback<Bundle>() {

        @Override
        public void run(AccountManagerFuture<Bundle> future) {
            try {
                String token = future.getResult().getString(AccountManager.KEY_AUTHTOKEN);

                //do something with token

                });


            } catch (Exception e) {
                //handle exception
                //this is where we get our OperationCancelledException
                e.printStackTrace();

            }
        }


    }, null);
} else {
    //handle not authed state
}

What could be causing this kind of error? Is the username at the end of the Mirror POST URL supposed to match something specific or are we free to use our own thing?

Omora answered 23/9, 2014 at 9:1 Comment(0)
D
1

A couple things to check:

  1. Does the package name of your application match exactly the package name provided when you submitted your Glassware?
  2. Have you installed your submitted APK at least once through MyGlass, instead of always side-loading it with adb? Make sure that you uninstall your APK and then install it by turning it on in MyGlass in order for the permissions to be set up correctly; from that point on, you can continue developing by replacing the APK over adb.
Disquiet answered 24/9, 2014 at 21:36 Comment(3)
Thanks for the reply Tony: 1. yes it does, although I may have slightly confused myself so just to double-check: the Mirror url is .../com.mycom.myapp.session/... , the token type is com.mycom.myapp.session, the account type is com.mycom.myapp.session, but the bundle ID is com.mycom.myapp . Is that all correct? 2. yes, I followed the steps: 1. factory reset glass, 2. installed over myglass by turning the app on, 3. installed a new version via ADB (signed with the same keystore) - both the myglass version and the new version throw the above exception.Omora
@Peter.. Are you able to solve the issue? I am also getting the same exception here.Sherman
@TaruniNeema we raised an issue with Google a couple of months ago and have been in semi-regular contact with support since. They are apparently still looking into it, which makes me think it is a bug their end. First I would try all of the suggestions above, but I will definitely also post back here when (if?) we get a fix from G.Omora

© 2022 - 2024 — McMap. All rights reserved.