Docs

Call Your API from Your Native/Mobile App

Everything you need to know to call your API from your native/mobile app

Ready to start building?

Using Auth0 in your applications means that you will be "outsourcing" the authentication process to a centralized login page in the same way that Gmail, YouTube, and any other Google property redirects to accounts.google.com whenever a user signs in.

Your user will authenticate, and Auth0 will generate an ID Token and Access Token that will be passed back to your application. The Access Token can then be used to call your API.

How it works

How it works

In a native/mobile application, the default experience will open a SafariViewController in iOS or a Custom Chrome Tab in Android.

When your app needs to fetch user data from your API:

  1. If the user is not already authenticated, our SDK redirects the user to your Auth0 Authorization Server.
  2. The user authenticates with Auth0 using one of your configured login options (e.g., username/password, social identity provider, SAMLSAML).
  3. Your app requests an ID Token, Access Token, and Refresh Token.
  4. Auth0 responds with the requested tokens.
  5. The Access Token can be used to call your API and retrieve requested data.

For security in native/mobile devices, Auth0 uses the Authorization Code Flow with Proof Key for Code Exchange (PKCE).

Flow Overview for Native/Mobile Apps

Implementation overview

Implementation overview

  1. 1

    Configure the sign-in methods

    Auth0 supports a wide range of authentication methods: regular username/password (users can be stored in Auth0 or your own database), social (i.e., Google, Facebook, and 50+ other providers), passwordless (email magic link, email code, and phone code), and enterprise (e.g., SAML-based, ADFS, Ping, Okta).

    Go to the dashboard and turn on the methods you want to allow; they will automatically show up in the login/sign-up page. By default, email/password and Google are enabled.
  2. 2

    Customize the sign-in UI (optional)

    The default experience is demonstrated in the image below and can be completely customized in the dashboard, from changing the logo and primary colors to completely overriding it with your own login screen.

    Default Login Screen for Native/Mobile Apps
  3. 3

    Use an SDK for your chosen platform to trigger the flow

    An open-source OpenID Connect (OIDC) SDK for your chosen platform can redirect to the Auth0 Universal Login page and handle the response, validating the ID Token.

    Your app can store the ID Token. Follow one of our Regular Web App Quickstarts to get started with the integration.
  1. 1

    Configure your API

    Once you have created your API, you will need to configure any scopes that applications can request during authorization.
  2. 2

    Get an Access Token

    Your app requests an Access Token (and optionally, a Refresh Token) from your Auth0 Authorization Server using the Authorization Code Flow with PKCE.
  3. 3

    Call your API

    When your app calls your API, it includes the retrieved Access Token in the HTTP Authorization header.
  4. 4

    Refresh your Access Token

    When the Access Token expires you can use the Refresh Token to get a new one from your Auth0 Authorization Server.

The easiest way to implement the Authorization Code Flow with PKCE is to follow our Mobile/Native Quickstarts.

You can also use our mobile SDKs:

Finally, to use our API endpoints, you can follow our tutorial: Call Your API Using the Authorization Code Flow with PKCE.

Keep reading

Keep reading

What's next


Ready to start building?