Question

I am using scribe 1.3.3 for OAuth2 in my android application.

I have gotten the full flow to work correctly with google, I can request user information and everything works fine.

I'm curious as to how to keep the user logged in if they close the app. Currently every time I start up the app I prompt the user to allow access.

How do I make it so that they only have to allow access once and from then on I just remember the user?

Was it helpful?

Solution

You don't have to remember the user. All you have to do is to remember the access token you got the first time. You can store it in shared preferences and use it to sign new requests.

So, the first time your activity starts you have to check whether the token is stored or not. You ask for credential only if the token is empty. Also note that your token may expire and if you get a 401 error you'll have to re authenticate the user.

PS: I wrapped scribe in an android library to make it easier to use with android: https://github.com/fedepaol/PostmanLib--Rings-Twice--Android

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top