
We always encounter the need for authentication in most of our applications. It's a struggling process to authenticate the user by interacting with services like Twitter, Facebook and so on.
Figure 1: Login
Here I'm creating a simple method of authentication using Xamarin.Auth.
The Xamarin.Auth component is a great time saver for authentication.
The authentication cardinals are given for authentication. Authenticators are responsible for managing the user interface and communicating with authentication services. Authenticators take a variety of parameters, like the Client ID, its authorization scope, the authorization URL, redirect URL and so on, since it varies depending on the authenticators.
- var auth = new OAuth2Authenticator
- (
- clientId: "", // your OAuth2 client id
- scope: "", // the scopes for the particular API you're accessing, delimited by "+" symbols
- authorizeUrl: new Uri(""), // the auth URL for the service
- edirectUrl: new Uri("")
- );
- auth.Completed += (sender, args) =>
- {
- if(args.IsAuthenticated)
- {
- var account =args.Account;
- // Do success work
- }
- else
- {
- // The user cancelled
- {
- };
All the info about the successful authentication will be in args.Account.
The GetUI() method returns the corresponding UINavigationController in iOS and corresponding Intent in Android.
- //iOS
- PresentViewController (auth.GetUI (), true, null);
- //Android
- activity.StartActivity(auth.GetUI(activity));
- // On iOS:
- AccountStore.Create ().Save (args.Account, "Facebook");
- // On Android:
- AccountStore.Create (this).Save (args.Account, "Facebook");
Xamarin.Auth provides all the popular services for authentication. We can also create our own authenticator by Username and Password using FormAuthenticator.SignInAsync().
A small sample of Authentication sample is added with this article as a reference.


qaz wsxPosted Jun 8, 2018, 2:54 AM EDT
Getting disallowed_useragent error for google, please help
Massimo De VitisPosted Apr 5, 2017, 10:07 AM EDT
Hi, it's possible to have a list of users facebook?
Massimo De VitisPosted Apr 5, 2017, 10:06 AM EDT
Hi, how it's possible to have the list of users ?
Veswanth RajuPosted Jan 11, 2017, 12:27 AM EST
Can you please tell me how to use FormAuthenticator.SignInAsync(); for my own authentication.
Vikas AgarwalPosted Aug 30, 2016, 4:48 AM EDT
I download this example and run it, but can't able to load login page. I have created xamarin pcl and want to click on fb icon for fb authentication it is possible with pcl in xamarin?
Akash KumarPosted Mar 17, 2016, 8:53 PM EDT
Can you send the steps to write the code for Facebook authentication?
Sudha SPosted Jan 5, 2016, 12:55 AM EST
Not able to see the login page, all can see is blank page
Vaikesh K PPosted Aug 16, 2015, 8:45 PM EDT
Thanks Pankaj Kumar Choudhary :)
Vaikesh K PPosted Aug 16, 2015, 8:44 PM EDT
Thanks Santhakumar Munuswamy sir :)
Vaikesh K PPosted Aug 16, 2015, 8:44 PM EDT
Thanks Nilesh Jadav :)
Vaikesh K PPosted Aug 16, 2015, 8:44 PM EDT
Thanks Sibeesh Venu :)
Vaikesh K PPosted Aug 16, 2015, 8:43 PM EDT
ThanksRajeesh Menoth
Vaikesh K PPosted Aug 16, 2015, 8:43 PM EDT
Thanks Rakesh Chavda Sir :)
Vaikesh K PPosted Aug 16, 2015, 8:43 PM EDT
Thanks Karthikeyan K :)
Pankaj Kumar ChoudharyTOP 100Posted Aug 16, 2015, 1:17 AM EDT
Nice article sir...
Santhakumar MunuswamyPosted Aug 15, 2015, 10:17 PM EDT
Nice Article. Thanks for sharing
Nilesh JadavPosted Aug 15, 2015, 1:13 AM EDT
Nice one Vaikesh K P
Sibeesh VenuTOP 100Posted Aug 15, 2015, 12:38 AM EDT
Nice Share :)
Rajeesh MenothPosted Aug 14, 2015, 11:32 PM EDT
Nice Share
RakeshPosted Aug 14, 2015, 11:31 PM EDT
nice one
Karthikeyan KPosted Aug 14, 2015, 10:16 PM EDT
Thanks for sharing