Auth0

Overview

Auth0 is a highly adaptable authentication and authorization platform. GoNative'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.

Implementation Guide

Once the premium module has been added to your app, you may use the following GoNative JavaScript Bridge commands to access its functionality.

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.

↔️GoNative JavaScript Bridge

To prompt Universal Login and retrieve a token:

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

Auth0 Universal Login

Logout

↔️GoNative JavaScript Bridge

To logout:

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

Support for Face ID / Touch ID / Android Biometrics

↔️GoNative JavaScript Bridge

gonative.auth0.loginUniversal({
  enableBiometrics: true,
  callback: gonative_auth0_post_login
});

gonative.auth0.status({ callback: gonative_auth0_status_beforelogin });

function gonative_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
    gonative.auth0.get({callback: gonative_auth0_biometric_login})
  }
}

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