0.2.1 • Published 6 years ago

@saphocom/auth0-plugin-cordova v0.2.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

auth0-js-plugin-cordova

Adds support for authentication in Cordova using plugins SafariViewController & Custom URL scheme.

Plugged in native browser (Chrome Custom Tab / Safari View Controller) instead of WebView allows you to use security providers that doesn't allow login in WebView for security reasons (like Google login) and gives your users a better UX experience (shared cookies with default browser, better navigation controls, etc.)

Installation

  1. Have SafariViewController & Custom URL scheme Cordova plugins installed in your Cordova project
  2. yarn install @saphocom/auth0-plugin-cordova or npm install @saphocom/auth0-plugin-cordova

Usage

import Auth0PluginCordova from '@saphocom/auth0-plugin-cordova';

var lock = new Auth0Lock(clientId, domain, {
    auth: {
        redirect: true, // Automatically FALSE in Cordova
        redirectUrl: "myapp://auth0/login",
        responseType: 'code',
    },
    plugins: [new Auth0PluginCordova()],
});

lock.show();

// ...

// Register cordova-plugin-customurlscheme handler 
function handleOpenURL(url) {
    if (url.startsWith("myapp://auth0/login")) {
        Auth0PluginCordova.finishAuth();
    }
}