Auth0

Overview

Auth0 is a highly adaptable authentication and authorization platform. Median's Auth0 Native Plugin implements the Auth0 iOS and Android SDK into your app.

The Auth0 integration allows you to request a login token from Auth0 using Universal Login and a native login UI. And optionally to store a refresh token to the secure device storage so that future logins are seamless using Face ID / Touch ID and Android Biometric. This biometric functionality is similar to our Face ID / Touch ID Android Biometric Native Plugin.

👍

Developer Demo

Display our demo page in your app to test during development https://median.dev/auth0

Implementation Guide

Configuration

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

{
  "domain": "median-test.auth0.com",
  "clientId": "q6jYUAy9e0c3MPOryIthwldSAAQFQhI",
  "scheme": "co.median.median-test"
}

These parameters should match the Application Settings on your Auth0 Dashboard.

Additionally you will need to verify that Deep Linking is configured properly for all domains listed under Universal Links / Deep Links and that a URL Scheme Protocol 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.

Login using Universal Login

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

↔️Median JavaScript Bridge

To prompt Universal Login and retrieve a token:

median.auth0.loginUniversal.then(function(){
  idToken: STRING,
  scope: STRING,
  error: STRING // if an error occurred
}
Auth0 Universal Login

Auth0 Universal Login

Logout

↔️Median JavaScript Bridge

To logout:

median.auth0.logout.then(function(){
  error: STRING // if an error occurred
}

Support for Face ID / Touch ID / Android Biometrics

↔️Median JavaScript Bridge

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

median.auth0.status({ callback: median_auth0_status_beforelogin });

function median_auth0_status_beforelogin(data){
  // can call to check status in advance of prompting biometrics
  // or prompt automatically
  // data.biometryAvailable: BOOL
  // data.biometryType: 'touchId' | 'faceId' | 'none'
  // data.hasRefreshToken: BOOL
  if(data && data.hasRefreshToken){
    // we have a refresh token in secure storage
    // automatically prompt biometrics to retrieve and login
    // alternatively could show a "Use Face ID" button
    median.auth0.get({callback: median_auth0_biometric_login})
  }
}

function median_auth0_biometric_login(data){
  if(data && data.status == 'success'){
    // Consume refreshToken to initiate a session in web environment
    customer_login_function(data.refreshToken);
  }
}