> ## Documentation Index
> Fetch the complete documentation index at: https://docs.median.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Auth0

> Add native Auth0 Universal Login to your app, store refresh tokens securely, and enable Face ID, Touch ID, and Android biometrics.

Auth0 is a highly adaptable authentication and authorization platform. Median's Auth0 Native Plugin implements the [Auth0 iOS](https://github.com/auth0/Auth0.swift) and [Android SDK](https://github.com/auth0/Auth0.Android) into your app.

The Auth0 integration allows you to request a login token from Auth0 using Universal Login and a native login UI. It can optionally store a refresh token in secure device storage, so that future sign-ins can use Face ID / Touch ID and Android Biometric. This biometric functionality is similar to our [Face ID / Touch ID Android Biometric](https://docs.median.co/docs/auth) Native Plugin.

> [!TIP]
>
> **Test  with our demo page**
>
> We host a ready-made demo page at
>
> that calls the  features through the Median JavaScript Bridge.
> Load it inside your Median app during development, either by setting it
> as your app's website URL in App Studio or by navigating to it from your
> own site, and use it to confirm  works on a real device before
> you add it to your own pages.
>
> The demo page only works inside a Median app with  enabled.
> Opened in a regular mobile or desktop browser, the native features
> won't respond. Remember to switch your app back to your own URL before
> release.

## Auth0 and app configuration

### Auth0 configuration

> [!WARNING]
>
> **Configuration disclaimer**
>
> Please be aware that the following steps provide a sample implementation to demonstrate the configuration for Median's Developer Demo. Auth0 is a highly customizable authentication and authorization service and the configuration below may not be suitable for your production environment. **We strongly recommend consulting with Auth0 experts to review and tailor your production configuration to your needs**.
>
> Additional information on the Auth0 Universal Login configuration for mobile applications can be found in the [Auth0 Native App Quickstart Guide](https://auth0.com/docs/quickstart/native#native).

#### Auth0 application type

Regardless of your existing Applications, Universal Login will require a new Native Application, as the Auth0 Quickstart Guide outlines.

![Native application type selected when creating an Auth0 application](https://mintcdn.com/median-co/TpSItjrYpkPK-i0N/images/docs/a7fa5032b8b2f6df1ec5e2aef86f50ac8d2d81153bab2f155e8b7473f52aeeb1-Screenshot_2025-09-08_at_14.45.53.png?fit=max\&auto=format\&n=TpSItjrYpkPK-i0N\&q=85\&s=ed702a74f8b8f3905e50f9a786d0b1ae)

Auth0 application type

#### Auth0 application URIs

As a next step after creating the application, you will need to configure the callback URIs for your Auth0 application. The configuration requires you to set up at minimum the Allowed Callback URLs and Allowed Logout URLs.

For our example configuration, we assume the following values:

| Key | Value | Source |
| - | - | - |
| Auth0 Domain | dev-tax7avdd0xmeaavx.us.auth0.com | Auth0 Dashboard |
| iOS Bundle ID | co.median.ios.ynbmjx | Median App Studio ([App Identifiers](https://docs.median.co/docs/app-identifiers.md#ios-bundle-id)) |
| Android Package Name | co.median.android.ynbmjx | Median App Studio ([App Identifiers](https://docs.median.co/docs/app-identifiers.md#android-package-name)) |

Based on the parameters above we can add the following three URLs to the Auth0 application configuration as allowed Callback URLs and Allowed Logout URLs:

```text theme={null}
demo://dev-tax7avdd0xmeaavx.us.auth0.com/android/co.median.android.ynbmjx/callback,
https://dev-tax7avdd0xmeaavx.us.auth0.com/ios/co.median.ios.ynbmjx/callback,
co.median.ios.ynbmjx://dev-tax7avdd0xmeaavx.us.auth0.com/ios/co.median.ios.ynbmjx/callback
```

You can learn more about the application URLs for your target platform (iOS and/or Android) in the respective [Auth0 Native App Quickstart Guide](https://auth0.com/docs/quickstart/native#native).

![Allowed Callback URLs and Allowed Logout URLs in the Auth0 application settings](https://mintcdn.com/median-co/7LCOHMhgIef7ewYE/images/docs/8c0dc2b5e753710e5f6edc559e2f56eeda6333cbfba2d0103b1d91ab0888047d-Screenshot_2025-09-08_at_15.02.49.png?fit=max\&auto=format\&n=7LCOHMhgIef7ewYE\&q=85\&s=e7c21f1233e4dfc291d5edcb9d345fac)

Auth0 callback and logout URLs

#### Advanced settings: device settings

Please populate your iOS bundle ID and Android Package name under Advanced Setting > Device Settings in the Auth0 Dashboard.

![iOS and Android settings under Advanced Settings > Device Settings in Auth0](https://mintcdn.com/median-co/TpSItjrYpkPK-i0N/images/docs/d3a3a85e5ad7ef455d172e83c17944fcdb876f2cec226477623922271734992c-Screenshot_2025-09-08_at_15.05.23.png?fit=max\&auto=format\&n=TpSItjrYpkPK-i0N\&q=85\&s=9d51ba936d187e2efc5427ee88ec8216)

Auth0 device settings

### App configuration

#### Link handling

##### Link handling rules

Verify the link handling rules for links to your Auth0 Domain. You can learn more about link handling in our [Link Behavior](https://docs.median.co/docs/internal-vs-external-links.md) article.

##### Universal deep links

Verify that [Deep Linking](https://docs.median.co/docs/deep-linking) is configured properly for all domains with **Universal Links** selected under **Link Handling → Universal Links / Deep Links / Web Credentials**.

##### URL scheme protocol

Verify a [URL Scheme Protocol](https://docs.median.co/docs/url-scheme-protocol.md) is specified for your app. The URL Scheme and all other values including Package Name and Bundle ID must match the parameters set in your Auth0 tenant.

#### Auth0 plugin configuration

The Auth0 Native Plugin requires several parameters to be set in App Studio, on the **Native Plugins** tab under "Advanced Mode". Sample parameters are as follows:

Median JavaScript Bridge

```json JSON theme={null}
{
  "domain": "dev-tax7avdd0xmeaavx.us.auth0.com",
  "clientId": "wTD****************KBwV",
  "scheme": "demo",
  "audience": "https://median-test.auth0.com/api/v2/"
}
```

Parameter notes:

* `scheme` is based on the URL scheme of your Android Callback URLs.
* `audience` is optional and based on your Auth0 tenant config.

These parameters should match the [Application Settings](https://auth0.com/docs/get-started/applications/application-settings) on your Auth0 Dashboard.

You can find an example configuration based on the parameters below.

![Auth0 plugin parameters in App Studio Advanced Mode](https://mintcdn.com/median-co/TpSItjrYpkPK-i0N/images/docs/b1fa03c2730f06cce914894ff62885da839d74127f55694cf551fd2b914ed057-Screenshot_2025-09-29_at_12.54.18.png?fit=max\&auto=format\&n=TpSItjrYpkPK-i0N\&q=85\&s=ddd8a63663b64cf8803a245ad6886e6e)

App Studio: Auth0 example configuration

## Implementation guide

### Sign in with Universal Login

Launch Universal Login via the Median JavaScript Bridge `login` method. Upon completion of Universal Login flow focus is returned to the app webview and a promise/callback function is invoked with the Auth0 tokens as parameters.

To prompt Universal Login and retrieve a token:

Median JavaScript Bridge

```javascript JavaScript theme={null}
const credentials = await median.auth0.login(
  {
    scope: "email profile offline_access" // optionally pass a scope
  }
);

// credentials object will have the following structure:
// {
// accessToken: string,
// idToken: string,
// scope: string,
// error: string, // if an error occurred
// refreshToken: string // with 'offline_access' scope configured
// }
```

![Auth0 Universal Login screen in the app](https://mintcdn.com/median-co/dZQPJ_0wlG7WNBTy/images/docs/3f6bdcc-image.png?fit=max\&auto=format\&n=dZQPJ_0wlG7WNBTy\&q=85\&s=7def2c1e27bbd013a17983153e92cda0)

Auth0 Universal Login

### Sign out

To sign out:

Median JavaScript Bridge

```javascript JavaScript theme={null}
median.auth0.logout().then(function (result) {
  // result.error is set if an error occurred
});
```

### Support for Face ID / Touch ID / Android biometrics

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Support for Face ID / Touch ID / Android Biometrics is enabled
// when signing in using the enableBiometrics parameter.

median.auth0.login({
enableBiometrics: true,
callback: median_auth0_post_login
});

// To determine if biometrics are enabled and available on the device
// after sign-in use the status method.

const auth0Status = await median.auth0.status();

// status object will have the following structure:
// hasValidCredentials indicates whether credentials are stored, and that the access token has not expired.
// {
// biometryAvailable: boolean,
// biometryType: 'touchId', 'faceId', or 'none',
// hasValidCredentials: boolean
// }
```

### Get saved credentials

Credentials are saved in the device secure storage and can be retrieved in later sessions. Retrieving saved credentials will automatically renew the tokens using the `refreshToken` already saved from the previous successful sign-in.

To get credentials saved in secure storage:

Median JavaScript Bridge

```javascript JavaScript theme={null}
const credentials = await median.auth0.getCredentials();

// credentials object will have the following structure:
// {
//   accessToken: string,
//   idToken: string,
//   scope: string,
//   error: string, // if an error occurred
//   refreshToken: string
// }
```

### Renew credentials

Retrieving the credentials automatically returns renewed credentials if the existing credentials are expired but you can also request to renew the credentials manually.

You can optionally pass a `refreshToken` to be used. By default, the method will use the refresh token saved from the previous successful sign-in.

To renew credentials manually:

Median JavaScript Bridge

```javascript JavaScript theme={null}
const credentials = await median.auth0.renew({
  refreshToken: '<refresh_token>' // optional
});
```

## Implementation checklist

### Auth0 platform configuration

* [ ] Set up a new Native or Single Page Web Application Auth0 app using the [Auth0 Quickstart Guides](https://auth0.com/docs/quickstart/native).
* [ ] Configure Allowed Callback URLs and Allowed Logout URLs based on your Auth0 tenant domain, iOS Bundle ID, and Android Package Name.
* [ ] Configured the Advanced Settings > Device Settings by providing iOS Team ID, and App ID as well as Android App Package Name and Key Hashes

### Median app and plugin configuration

* [ ] Configure link handling rules based on your Auth0 tenant domain.
* [ ] Add Deep Linking configuration for your Auth0 tenant domain.
* [ ] Verify or add URL Scheme Protocol configuration based on parameters set in your Auth0 tenant.
* [ ] Verify the Auth0 Plugin configuration and add required parameters: "domain," "clientId," "scheme," and (optionally) "audience."

### Website implementation

* [ ] Use `median.auth0.login` to launch the Auth0 plugin and initiate the authentication flow for app users.
* [ ] Use `median.auth0.logout` to provide app users with a sign-out method.
* [ ] Review JavaScript and Auth0 implementation to ensure the use of refresh tokens and enable biometrics.
* [ ] Set up and publicly host `[yourdomain]/.well-known/assetlinks.json` and `[yourdomain]/.well-known/apple-app-site-association` files to enable deep linking.

## Auth0 plugin demo

> [!WARNING]
>
> **Sample app note**
>
> The following demo details the JSON responses for each JavaScript Bridge function based on the configuration and setup outlined above. Please be aware that biometric functionality cannot be tested using iOS and Android simulators. A video showcasing Face ID/Touch ID and Android Biometrics support is included below for your reference.

[Median's Auth0 plugin](https://www.youtube.com/embed/AF_lfUog9sg)

## Frequently asked questions

> [accordion] Why should I integrate Median's Auth0 plugin and use Auth0 Universal Login?
>
> Median's Auth0 plugin makes use of the Auth0 iOS and Android native SDKs for the most secure app sign-in experience, consistent with best practices for managing authentication. To learn more about the security benefits of Auth0 Universal Login versus embedded login flows consult the Auth0 documentation discussing [Centralized Universal Login vs. Embedded Login](https://auth0.com/docs/authenticate/login/universal-vs-embedded-login#security-risks).

> [accordion] Can I support login on my own web page displayed within the app webview?
>
> Mobile security policies and the Internet Engineering Task Force (IETF) Best Current Practices (BCP) require that user login only be made in a browser session facilitated through a native app, and not be permitted in an embedded app webview itself. Google Sign-In, Facebook Login, and Auth0 hosted Universal Login make this mandatory.
>
> * [IETF RFC 8252: OAuth 2.0 for Native Apps](https://datatracker.ietf.org/doc/html/rfc8252)
> * [Auth0: OAuth 2.0 best practices for native apps](https://auth0.com/blog/oauth-2-best-practices-for-native-apps/)
> * [Google: security changes to OAuth 2.0 in embedded webviews](https://developers.googleblog.com/en/upcoming-security-changes-to-googles-oauth-20-authorization-endpoint-in-embedded-webviews/)
> * [Meta: deprecating Facebook Login on Android embedded browsers](https://developers.facebook.com/blog/post/2021/06/28/deprecating-support-fb-login-authentication-android-embedded-browsers/)
>
> Our Social Login and Auth0 plugins are the recommended solutions for authentication within your app as they offer the corresponding native SDKs that meet security policies and follow best practices.


## Related topics

- [Changelog archive](https://docs.median.co/docs/changelog-archive.md)
- [Authentication](https://docs.median.co/docs/authentication.md)
- [Using Social Login in your Shopify store's mobile app](https://docs.median.co/docs/using-social-login-in-the-mobile-app-of-your-shopify-store.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.