Create a token to access your google account

I have a problem creating a second token in my application. I registered 2 accounts on my phone. When I use the first token of the account, it generates, but when I select the second token it is not generated. My code is:

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 $ AmsTaskrror Account. java: 1572) android.accounts.IAccountManagerResponse $ Stub.onTransact (IAccountManagerResponse.java:69) android.os.Binder.execTransact (Binder.java:407) dalvik.system.NativeStart.run (native method)

+6
source share
1 answer

The second parameter in getAuthTokenByFeatures must be a valid scope (for example: oauth2:https://gdata.youtube.com )

+1
source

Source: https://habr.com/ru/post/975681/


All Articles