Windows Phone

Community maintained

Sample Project

Download a sample project specific to this tutorial configured with your Auth0 API Keys.

System Requirements
  • Microsoft Visual Studio 2015
  • Auth0.WindowsPhone 1.5.0
Show requirements

1. Install the Auth0.WindowsPhone package

You can either run the following command or install it via the Package Manager UI.

Install-Package Auth0.WindowsPhone

2. Setting up the callback URL in Auth0

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


3. Instantiate the Auth0 client

Add static property to App class to save your authentication client

public static Auth0Client Auth0 { get; private set; }

Provide your domain and application's Client ID as parameters when creating the client instance and save to that property:

For Windows Phone XAML add initialization code to the end of App constructor

public App()
    this.Suspending += this.OnSuspending;

    Auth0 auth0Client = new Auth0Client("YOUR_AUTH0_DOMAIN", "YOUR_CLIENT_ID");

For Windows Phone Silverlight add initialization code to the end of InitializePhoneApplication method before phoneApplicationInitialized = true;

private void InitializePhoneApplication()
    Auth0 Auth0Client auth0Client = new Auth0Client("YOUR_AUTH0_DOMAIN", "YOUR_CLIENT_ID");

    // Ensure we don't initialize again
    phoneApplicationInitialized = true;

4. Allow users to log in

The simplest way is to simply call:

    var user = await App.Auth0.LoginAsync();
    // Do whatever you need with a user
catch (AuthenticationCancelException)
    // Handle case when user canceled authentication
catch (AuthenticationErrorException)
    // Handle case when some error happen while authentication
catch (AuthenticationException)
    // Handle all Auth0 Authentication error cases

If you want to specify a particular connection you can do that using:

var user = await App.Auth0.LoginAsync("{CONNECTION_NAME}");

Alternatively, if you want to allow database users to sign in and you have their credentials in memory:

var user = await App.Auth0.LoginAsync("{CONNECTION_NAME}", "{USER_NAME}", "{PASSWORD}");

5. Use server API if necessary:

var client = new HttpClient();

// Accessing public resource
var response = await client.GetAsync(new Uri("{YOUR API URL}/{PUBLIC RESOURCE}"));

// Accessing secured resource
// Initialize HTTP request message
var message = new HttpRequestMessage(HttpMethod.Get, new Uri("{YOUR API URL}/{SECURED RESOURCE}"));
// Add header so that server can recognize logged in user
message.Headers.Add("Authorization", "Bearer " + App.Auth0.CurrentUser.IdToken);
response = await client.SendRequestAsync(message);

6. Sit back and relax

Now it's time to sit back and relax. You've implemented login and signup with Auth0 for your Windows Phone application.

7. More Information

You can also check out the Github page access the source code, and additional documentation.

Use Auth0 for FREECreate free Account