I have a question about authentication using the Android Account Manager. We have a backend and an Android app and the user should log into our backend using his Facebook account. Currently we show a webview for this purpose which does normal oAuth 2 but using the Android Account Manager is more secure and much easier for the user so we want to switch. My question is, how can the server validate if the user is really who he pretends to be. Since we cant trust the App we have to talk to fb from the server side to validate if the user really is who he pretends to be. Based on a quite similar idea I made the following diagram to ask you if this is the correct way to do it or if I missed something:
The flow would look like this:
So is this the correct way? Is step 6 a good idea to pass the token once to "my server" or is there a better way? Btw Facebook is just an example here, we use different auth providers like FB, Google and Twitter but the flow should be the same for each one.
Updated on August 27, 2021: We will continue to support FB Login authentication on Android embedded browsers until October 5, 2021. Based on developer feedback, we are providing additional time for developers to plan for the deprecation of FB Login authentication on Android embedded browsers.
Authenticate Using Facebook Login on Android. You can let your users authenticate with Firebase using their Facebook accounts by integrating Facebook Login into your app. Before you begin. If you haven't already, add Firebase to your Android project.
Use AccountManager to learn the user's account name (s). Use OAuth2 to help users get permission to access web services without needing to type in a login name or password. Add your own account type to the Android Account Manager.
Add a custom account to the user's device to authenticate your own back-end services Use AccountManager to learn the user's account name (s). Use OAuth2 to help users get permission to access web services without needing to type in a login name or password. Add your own account type to the Android Account Manager.
I don't know if this the correct way or not. But i'd like to share how we tackled this problem in our case which was pretty much same as your solution. We were using Google and Facebook auth providers.
Our android app sends token to the server and then server validate the token depending on the provider if it is validated then user is good to go if it isn't we show the appropriate message. Also we used to check the validation of token every time when user open the app at server end if token is still valid user can use app if it is not we just bring user back to log in screen so user can validate himself again because token get expired after some time.
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