Q:

Authentication Android with token

I read a lot of things about authentication, but I don't know what's the best way to proceed. 
How to create a token ?  Should I use OAuth2 ? 
Can I store this token in SharedPreference to keep session alive when the user closes/reopens the app and when he uses the app ?  Is it secured ? 
I'm a bit lost. 
Thanks a lot. 

A:

In general it is a good idea to store token instead of passwords and usernames.  So you can authenticate against a system and do that things you need to do.  For more background why storing passwords is a bad idea: Passwords are often used on multiple platforms so if an attacker get one password the user has a big damage, while token expire and can been renewed often without any user interaction. 
Typically you get tokens with OAuth sometimes also with a initial credentials authentification.  In the end you have a token which you to send to each request so the server will know who you are. 
You can safely store those tokens.  I hope that helps.