Every app needs user data and facebook and twitter are the most convinient and used social networks to get the user data from. In our app, we have given the facility for the user to sign up and log in using their facebook or twitter credentials.
Facebook has a really great guide to get started with Facebook SDK for Android. You can find it here. We used this guide to build the basic authentication steps.
After registering your app with facebook, you can test your app. Facebook SDK for Android is really easy to use and it handles everything from async reuqests, callbacks to threads. So we need not worry about it at all.
We used Session.openActiveSession method to create a new session and we passed the key parameters for which we required the data. Once the seesion is active, it calls the callback method where we create a Request to get
GraphUser. Once the request goes through, it returns the GraphUser and Response.
Once we obtain the facebook ID of the user, we can easily get the user’s profile picture with a simple
We just link the facebook id to the user and can directly log the user in based on the facebook id.
P.S. Next post on Twitter.