Windows Universal App C#

Community maintained

Sample Project

Download this sample project configured with your Auth0 API Keys.

System Requirements
  • Microsoft Visual Studio 2015
  • Windows 10 SDK (10.0.14393)
Show requirements

This tutorial explains how to integrate Auth0 login with a Windows UWP (Universal Windows Platform) C# application. The Nuget package Auth0.Windows.UWP helps you authenticate users with any Auth0 supported identity provider.

Install the Auth0.Windows.UWP NuGet Package

Use the NuGet Package Manager Console (Tools -> Nuget Package Manager -> Package Manager Console) to install the Auth0.Windows.UWP package, running the command:

Install-Package Auth0.Windows.UWP

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 to do the integration:

  1. Using the Auth0 Login Widget with the Web Authentication Broker (this is the simplest with only a few lines of code required).
  2. Using the Auth0 Login Widget with the Web Authentication Broker, but specifying a specific Connection.
  3. A custom user interface to ask username and password.

Option 1: Auth0 Lock

To start, we recommend using the Login Widget. Here is a snippet of code to copy & paste on your project. Since we are using await (.NET 4.5 or greater), your method needs to be async:

using Auth0.LoginClient;

var auth0 = new Auth0Client(
var user = await auth0.LoginAsync();
    Use this object to do wonderful things, e.g.:
      - get user email => user.Profile["email"].ToString()
      - get Windows Azure AD groups => user.Profile["groups"]
      - etc.

Option 2: Auth0 Lock with a Specific Connection

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

var user = await auth0.LoginAsync("") // connection name here

connection names can be found on Auth0 dashboard. E.g.: facebook, linkedin,, saml-protocol-connection, etc.

Option 3: Custom User Interface

The third option is to create your own custom user interface to prompt the user for their username and password. You can then pass this, along with the connection name to the LoginAsync method:

var user = await auth0.LoginAsync(
  "my-db-connection",   // connection name here


Optionally you can specify the scope parameter. There are various possible values for scope:

  • scope: "openid" (default) - It will return, not only the access_token, but also an id_token which is a Json Web Token (JWT). The JWT will only contain the user id.
  • scope: "openid {attr1} {attr2} {attrN}" - If you want only specific user's attributes to be part of the id_token (For example: scope: "openid name email picture").

You can get more information about this in the Scopes documentation.

Capabilities (Optional)

In some cases, Auth0 may not be able to connect to an identity provider. Showing nothing more than a "Can't connect to the service" message. A reason for this may be that the identity provider endpoint resolves to an Intranet (that has an authenticated domain controller), home or work network. In this case it is required to enable the "Private Networks (Client & Server)" capability.

Use the Package Manifest (Solution Explorer > Package.appxmanifest) to enable the capability within the "Capabilities" tab.

Accessing 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: is a Json Web Token (JWT) containing all of the user attributes and it is signed with your client secret. This is useful to call your APIs and flow the user identity.
  • Auth0AccessToken: the access_token that can be used to access Auth0's APIs. For example, you could use this token to Link Accounts.
Use Auth0 for FREECreate free Account