android - How AccountManager knows what Google account to use? -


i trying implement google rest api drive v3 in android.

but getting autherror

{    "error":{       "errors":[          {             "domain":"global",             "reason":"autherror",             "message":"invalid credentials",             "locationtype":"header",             "location":"authorization"          }       ],       "code":401,       "message":"invalid credentials"    } } 

i use accountmanager token user, , think access wrong console account.
how know account access?

this accountmanager code, user token. invalidate before accountmanager.invalidateauthtoken

    bundle options = new bundle();     options.putstring(accountmanager.key_android_package_name, context.getpackagename());     accountmanager.getauthtoken(account, scope, options, context,             callback, null); 

as per account manager docs [getauthtoken](http://developer.android.com/reference/android/accounts/accountmanager.html#getauthtoken(android.accounts.account, java.lang.string, android.os.bundle, android.app.activity, android.accounts.accountmanagercallback, android.os.handler)):

gets auth token of specified type particular account, prompting user credentials if necessary. method intended applications running in foreground makes sense ask user directly password.

if generated auth token cached account , type, returned. otherwise, if saved password available, sent server generate new auth token. otherwise, user prompted enter password.

it seems may depend on value of account variable passing in getauthtoken().

you have in, gonna included in community, did include use_credentials permission mentioned in docs:

note: if targeting app work on api level 22 , before, use_credentials permission needed platforms.

hope helps. luck. :)


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -