System Requirements

This tutorial has been tested with the following:

  • Microsoft Visual Studio 2015
  • Xamarin for Visual Studio 4.2

This tutorial explains how to integrate Auth0 with a Xamarin application.

The Xamarin.Auth0Client helps you authenticate users with any Auth0 supported identity provider via the OpenId Connect protocol built on top of OAuth2. The library is cross-platform, so this information can be applied to either iOS or Android.

NOTE: An Objective-C Binding Library for Lock iOS implementations is available at: Lock.Xamarin.

Install Xamarin.Auth0Client Component

In order to include Xamarin.Auth0Client component, please perform the following steps:

  1. With the project loaded in Xamarin Studio (or Visual Studio), right-click on the Components folder in the Solution Explorer and select Get More Components.
  2. Search and double-click on Auth0Client component.
  3. From the component page, select the Add to Project button to download the component and add it to the current project.

For more information, see: How to include a Component in a Xamarin Project.

Set up the Auth0 Callback URL

Go to the Client Settings section in the Auth0 dashboard and make sure that Allowed Callback URLs contains the following value:



There are three options for implementing the integration:

  1. Use the Auth0 Lock inside a Web View - the simplest option with only a few lines of code required.
  2. Create your own UI - more work, but higher control over the UI.
  3. Use a specific username and password.

Option 1: Auth0 Lock

Lock is the recommended option.

Here is a snippet of code to paste into your project:

using Auth0.SDK;

var auth0 = new Auth0Client(
// 'this' could be a Context object (Android) or UIViewController, UIView, UIBarButtonItem (iOS)
var user = await auth0.LoginAsync(this);
- get user email => user.Profile["email"].ToString()
- get Windows Azure AD groups => user.Profile["groups"]
- etc.

Component info

Xamarin.Auth0Client is built on top of the WebRedirectAuthenticator in the Xamarin.Auth component. All rules for standard authenticators apply regarding how the UI will be displayed.

Option 2: Custom User Interface

If you know which identity provider you want to use, you can add the connection parameter and the user will be directed to the specified connection:

var user = await auth0.LoginAsync(this, "google-oauth2"); // connection name here

NOTE: Connection names can be found on Auth0 dashboard (e.g. facebook, linkedin, saml-protocol-connection).

Option 3: Specific Username and Password

var user = await auth0.LoginAsync(
  "sql-azure-database",     // connection name here
  "jdoe@foobar.com",        // user name
  "1234");                 // password

Access User Information

The Auth0User has the following properties:

  • Profile: returns a Newtonsoft.Json.Linq.JObject object from Json.NET component containing all available user attributes (e.g.:user.Profile["email"].ToString()).
  • IdToken: a JSON Web Token (JWT) containing all of the user attributes and signed with your client secret.
  • Auth0AccessToken: the access_token that can be used to call the Auth0 APIs. For example, you could use this token to Link Accounts.

Download samples

Android and iOS samples are available on GitHub at: Xamarin.Auth0Client.

Use Auth0 for FREECreate free Account