i can login with Android AccountManager
with this code:
http://code.google.com/p/google-api-java-client/wiki/AndroidAccountManager
But i don't know how to log out?
You don't. When you use the built-in android authentication, you authenticate using the username and password that the user has provided in the "Accounts and Sync" control panel. Once you have that authentication, you use it to obtain an auth-token which you should cache and use until it goes bad.
So, let's go with the way you access google services using a "com.google" style account. You will end up authenticating using AccountManager, when your app wants to sync (You should definitely be using a SyncAdapter to do this). Once you authenticate, you will get an auth-token. this is a big string of random letters, which acts as a "key" on subsequent web calls. You will save this, and as long as it's good, you won't need to authenticate again. So, want go to fetch... let's say, a google finance portfolio. You include the auth-token as part of the http get header. One of two things happens:
The latter case will happen for two reasons:
In any case, you never log out. You just use the service with the auth token you've obtained and cached, until you don't anymore. Think of the auth token you get as being like a session key that stays good for as long as you're using it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With