@saphocom/auth0-plugin-cordova
v0.2.1
Published
auth0.js plugin for auth flow handling in Cordova environment.
Downloads
23
Maintainers
Readme
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
- Have SafariViewController & Custom URL scheme Cordova plugins installed in your Cordova project
yarn install @saphocom/auth0-plugin-cordova
ornpm 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();
}
}