android - How can i log out with AndroidAccountManager -


i can login android accountmanager code: http://code.google.com/p/google-api-java-client/wiki/androidaccountmanager

but don't know how log out?

you don't. when use built-in android authentication, authenticate using username , password user has provided in "accounts , sync" control panel. once have authentication, use obtain auth-token should cache , use until goes bad.

so, let's go way access google services using "com.google" style account. end authenticating using accountmanager, when app wants sync (you should using syncadapter this). once authenticate, auth-token. big string of random letters, acts "key" on subsequent web calls. save this, , long it's good, won't need authenticate again. so, want go fetch... let's say, google finance portfolio. include auth-token part of http header. 1 of 2 things happens:

  1. google likes token , uses (in place of of username/password pair) authenticate you, , returns data request.
  2. google returns http error 40x indicating auth-token youp provided no good.

the latter case happen 2 reasons:

  1. it's old. google likes re-authenticate periodically (just have enter password @ gmail.com every week or 2 make sure it's still you.) when happens, invalidate auth token (there's function call) , new one.
  2. the user has changed password since got auth token. same thing, except along way, device fail authenticate, , complain user need re-enter password, , until do, you'll either null auth token, or call block until password (depending on function call use token).

in case, never log out. use service auth token you've obtained , cached, until don't anymore. think of auth token being session key stays long you're using it.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -