Press "Enter" to skip to content

Social Media Authentication – Facebook login in Xamarin Forms

When developing a mobile applications is very common to support  authentication from social media networks such as Facebook, Instagram, Google, Twitter, Microsoft, LinkedIn to facilitate users onboarding process. In this series of articles, I will be showing how to do the client side integration of each.

The order of the series will be the following:

  • Article 1: Facebook
  • Article 2: Instagram
  • Article 3: Google
  • Article 4: Twitter
  • Article 5: Microsoft
  • Article 6: LinkedIn

Facebook Authentication 

To handle this integration we have some options like using the native SDKs, in my case will be using my plugin Plugin.FacebookClient which provides a common cross platform (iOS and Android) api to interact with Facebook.

The result will look like this:

Let’s start

1-Do the Facebook portal setup 

I won’t talk much about this since you can find instructions in the README of my plugin where I have step by step instructions on how to set it up, you can check it here.

2-Install the Plugin.FacebookClient in each project

3-Initialize and setup the plugin on Android/iOS

You can check how to do it with this guide I wrote a few months ago.

4-Create a ViewModel and add the Facebook authentication call 

To authenticate will call RequestUserDataAsync method which triggers login and also request the user data. I can specify which fields I want to obtain after login and set the permissions that will be requested to the user.

Will listen to event OnUserData that is called after login is completed or canceled.

5-Create the Facebook button UI

Is important to follow the Facebook guidelines for the button, you can check more information here.


That’s it, keep posted to the Instagram article next week 🙂

Check the full source code here.

Happy facebook integration!

3 Comments

  1. vipin vipin

    thanks

  2. Asaf Asaf

    thanks

Comments are closed.