Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating token to access google account

I've a problem with generating a second token in my application. I registered 2 accounts on my phone. When I use the first account token is generating, but when I choose the second token isn't generated. My code:

accountManager.getAuthTokenByFeatures("com.google", "Manage your tasks", null, this,
                             Bundle.EMPTY, Bundle.EMPTY, new AccountManagerCallback<Bundle>() {
                                @Override
                                public void run(AccountManagerFuture<Bundle> bundleAccountManagerFuture) {
                                    try {
                                        String token = bundleAccountManagerFuture.getResult()
                                                .getString(AccountManager.KEY_AUTHTOKEN);
                                        Log.e("token", token);
                                    } catch (AuthenticatorException e) {
                                        e.printStackTrace();
                                    } catch (OperationCanceledException e) {
                                        e.printStackTrace();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }, null);

I get the following errors:

android.accounts.AuthenticatorException: Unknown android.accounts.AccountManager.convertErrorToException(AccountManager.java:1726) android.accounts.AccountManager.access$400(AccountManager.java:144) android.accounts.AccountManager$AmsTask$Response.onError(AccountManager.java:1572) android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69) android.os.Binder.execTransact(Binder.java:407) dalvik.system.NativeStart.run(Native Method)

like image 673
elektronik Avatar asked Sep 22 '14 20:09

elektronik


1 Answers

The second parameter in getAuthTokenByFeatures should be a valid scope (eg: oauth2:https://gdata.youtube.com)

like image 52
kungfoo Avatar answered Oct 03 '22 00:10

kungfoo