2

I am trying to use the Android account manager for creating my app's own account, so I have studied the example provided in the SDK. However, I have a little problem understanding how I have to manage the authentication token on the server.

From what I understood when studying the example and reading some tutorials is that the user will have to provide his login and password when he will first log in. Then the account manager will ask my server for a token associated to the user credentials. This token will be stored as the password in the account on the Android device (so the real password is never stored on the device).

Because the tokens expire regularly, I understand that my server has to be able to generate a new token with a login and an expired token. Is that correct? How can I generate a new token from an old one?

Moreover, what should be the structure of the token? How do I generate it? Has the expire time to be stored in the token itself or on my server?

EDIT: If someone has a simple working example to show me, it would help me very much. Also, if you have other information than the answer below, please post it, as Amokrane Chentir's answer did not help me. Indeed, calling AccountManager#getAuthToken() results in calling the method getAuthToken() I have to implement in my AbstractAccountAuthenticator's subclass.

EDIT2: I'm still interested by a solution to this problem, 5 months later :)

Romain Guidoux
  • 2,943
  • 4
  • 28
  • 48

1 Answers1

0

You can call the method AccountManager#invalidateAuthToken to request a new Auth Token. Also, you don't need to generate an Auth Token yourself, you have to use AccountManager#getAuthToken.

Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158