UNPKG

react-native-auth0

Version:
992 lines (981 loc) 38.7 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1" /> <title>Home - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" /> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css" /> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css" /> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <li class="nav-link nav-home-link"><a href="index.html">Home</a></li> <li class="nav-heading">Classes</li> <li class="nav-heading"> <span class="nav-item-type type-class">C</span ><span class="nav-item-name"><a href="Auth.html">Auth</a></span> </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.authorizeUrl">authorizeUrl</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.createUser">createUser</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.exchange">exchange</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.exchangeNativeSocial" >exchangeNativeSocial</a ></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.loginWithEmail">loginWithEmail</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.loginWithSMS">loginWithSMS</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.logoutUrl">logoutUrl</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.passwordlessWithEmail" >passwordlessWithEmail</a ></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.passwordlessWithSMS" >passwordlessWithSMS</a ></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.passwordRealm">passwordRealm</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.refreshToken">refreshToken</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.resetPassword">resetPassword</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.revoke">revoke</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Auth.html#.userInfo">userInfo</a></span > </li> <li class="nav-heading"> <span class="nav-item-type type-class">C</span ><span class="nav-item-name"><a href="Auth0.html">Auth0</a></span> </li> <li class="nav-heading"> <span class="nav-item-type type-class">C</span ><span class="nav-item-name" ><a href="Auth0.module.exports.html">module.exports</a></span > </li> <li class="nav-heading"> <span class="nav-item-type type-class">C</span ><span class="nav-item-name"><a href="Users.html">Users</a></span> </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Users.html#.getUser">getUser</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="Users.html#.patchUser">patchUser</a></span > </li> <li class="nav-heading"> <span class="nav-item-type type-class">C</span ><span class="nav-item-name"><a href="WebAuth.html">WebAuth</a></span> </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="WebAuth.html#.authorize">authorize</a></span > </li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="WebAuth.html#.clearSession">clearSession</a></span > </li> <li class="nav-heading"><a href="global.html">Globals</a></li> <li class="nav-item"> <span class="nav-item-type type-function">F</span ><span class="nav-item-name" ><a href="global.html#users">users</a></span > </li> </nav> <div id="main"> <section class="readme"> <article> <h1>react-native-auth0</h1> <p> React Native toolkit for Auth0 API, compliant with <a href="https://tools.ietf.org/html/rfc8252">RFC 8252</a> </p> <p> <a href="https://circleci.com/gh/auth0/react-native-auth0" ><img src="https://img.shields.io/circleci/project/github/auth0/react-native-auth0.svg?branch=master&amp;style=flat-square" alt="Build Status" /></a> <a href="https://npmjs.org/package/react-native-auth0" ><img src="https://img.shields.io/npm/v/react-native-auth0.svg?style=flat-square" alt="NPM version" /></a> <a href="https://codecov.io/github/auth0/react-native-auth0" ><img src="https://img.shields.io/codecov/c/github/auth0/react-native-auth0.svg?style=flat-square" alt="Coverage" /></a> <a href="#license" ><img src="https://img.shields.io/npm/l/react-native-auth0.svg?style=flat-square" alt="License" /></a> <a href="https://npmjs.org/package/react-native-auth0" ><img src="https://img.shields.io/npm/dm/react-native-auth0.svg?style=flat-square" alt="Downloads" /></a> <a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Freact-native-auth0?ref=badge_shield" ><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauth0%2Freact-native-auth0.svg?type=shield" alt="FOSSA Status" /></a> </p> <h2>Important Notices</h2> <p> Version <strong>2.9.0</strong> introduced a <strong>breaking change</strong> to the Android configuration. Previously it was required to add an intent filter in the definition of the Activity that receives the authentication result, and to use the <code>singleTask</code> <strong>launchMode</strong> in that activity. Now both the intent filter and the launch mode must be removed and instead you need to add a couple of manifest placeholders. Check out the <a href="#android">Android</a> section for more details. </p> <h2>Table of Contents</h2> <ul> <li><a href="#documentation">Documentation</a></li> <li><a href="#requirements">Requirements</a></li> <li><a href="#getting-started">Getting Started</a></li> <li><a href="#usage">Usage</a></li> <li><a href="#support--feedback">Support + Feedback</a></li> <li> <a href="#vulnerability-reporting">Vulnerability Reporting</a> </li> <li><a href="#thank-you">Thank You</a></li> <li><a href="#what-is-auth0">What is Auth0</a></li> <li><a href="#license">License</a></li> </ul> <h2>Documentation</h2> <ul> <li> The <a href="https://auth0.com/docs/quickstart/native/react-native" >React Native Quickstart</a > shows how to get an iOS or Android app running from scratch. </li> <li> The <a href="https://github.com/auth0-samples/auth0-react-native-sample/tree/master/00-Login" >React Native Sample</a > has complete, running iOS and Android applications you can try. </li> <li> The <a href="#usage">Usage</a> section below covers specific use cases outside of basic authentication. </li> <li> The <a href="https://auth0.github.io/react-native-auth0/" >API documentation</a > is generated from the code and explains all methods that are able to be used. </li> </ul> <h2>Requirements</h2> <p> This SDK targets apps that are using React Native SDK version <code>0.60.5</code> and up. If you're using an older React Native version, see the compatibility matrix below. </p> <h3>Compatibility Matrix</h3> <p> This SDK attempts to follow <a href="https://semver.org/">semver</a> in a best-effort basis, but React Native is still making releases that eventually include breaking changes on it making this approach difficult for any React Native library module. Use the table below to find the version that best suites your application. </p> <table> <thead> <tr> <th style="text-align:center">React Native SDK</th> <th style="text-align:center">Auth0 SDK</th> </tr> </thead> <tbody> <tr> <td style="text-align:center">v0.62.2</td> <td style="text-align:center">v2.5.0</td> </tr> <tr> <td style="text-align:center">v0.60.5</td> <td style="text-align:center">v2.0.0</td> </tr> <tr> <td style="text-align:center">v0.59.0 or lower</td> <td style="text-align:center">v1.6.0</td> </tr> </tbody> </table> <p> The contents of previous release can be found on the <a href="https://github.com/auth0/react-native-auth0/tree/v1" >branch v1</a >. </p> <h2>Getting Started</h2> <p>First install the native library module:</p> <h3>With <a href="https://www.npmjs.com">npm</a></h3> <p><code>$ npm install react-native-auth0 --save</code></p> <h3>With <a href="https://yarnpkg.com/en/">Yarn</a></h3> <p><code>$ yarn add react-native-auth0</code></p> <p> Then, you need to run the following command to install the ios app pods with Cocoapods. That will auto-link the iOS library: </p> <p><code>$ cd ios &amp;&amp; pod install</code></p> <h3>Configuration</h3> <p> You need make your Android and iOS applications aware that an authentication result will be received from the browser. This SDK makes use of the Android's Package Name and its analogous iOS's Product Bundle Identifier to generate the redirect URL. Each platform has its own set of instructions. </p> <h4>Android</h4> <blockquote> <p> Before version 2.9.0, this SDK required you to add an intent filter to the Activity on which you're going to receive the authentication result, and to use the <code>singleTask</code> <strong>launchMode</strong> in that activity. To migrate your app to version 2.9.0+, remove both and continue with the instructions below. </p> </blockquote> <p> Open your app's <code>build.gradle</code> file (typically at <code>android/app/build.gradle</code>) and add the following manifest placeholders: </p> <pre class="prettyprint source lang-groovy"><code>android { defaultConfig { // Add the next line manifestPlaceholders = [auth0Domain: &quot;YOUR_AUTH0_DOMAIN&quot;, auth0Scheme: &quot;${applicationId}&quot;] } ... } </code></pre> <p> The <code>auth0Domain</code> value must be replaced with your Auth0 domain value. So if you have <code>samples.auth0.com</code> as your Auth0 domain you would have a configuration like the following: </p> <pre class="prettyprint source lang-groovy"><code>android { defaultConfig { manifestPlaceholders = [auth0Domain: &quot;samples.auth0.com&quot;, auth0Scheme: &quot;${applicationId}&quot;] } ... } </code></pre> <p> The <code>applicationId</code> value will be auto-replaced on runtime with the package name or id of your application (e.g. <code>com.example.app</code>). You can change this value from the <code>build.gradle</code> file. You can also check it at the top of your <code>AndroidManifest.xml</code> file. </p> <p> If you use a value other than <code>applicationId</code> in <code>auth0Scheme</code> you will also need to pass it as the <code>customScheme</code> option parameter of the <code>authorize</code> and <code>clearSession</code> methods. </p> <p> Take note of this value as you'll be requiring it to define the callback URLs below. </p> <blockquote> <p> For more info please read the <a href="https://facebook.github.io/react-native/docs/linking.html" >React Native docs</a >. </p> </blockquote> <h4>iOS</h4> <p> Inside the <code>ios</code> folder find the file <code>AppDelegate.[swift|m]</code> add the following to it: </p> <pre class="prettyprint source lang-objc" ><code>#import &lt;React/RCTLinkingManager.h> - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary&lt;UIApplicationOpenURLOptionsKey, id> *)options { return [RCTLinkingManager application:app openURL:url options:options]; } </code></pre> <p> Inside the <code>ios</code> folder open the <code>Info.plist</code> and locate the value for <code>CFBundleIdentifier</code>, e.g. </p> <pre class="prettyprint source lang-xml" ><code>&lt;key>CFBundleIdentifier&lt;/key> &lt;string>$(PRODUCT_BUNDLE_IDENTIFIER)&lt;/string> </code></pre> <p> and then below it register a URL type entry using the value of <code>CFBundleIdentifier</code> as the value for <code>CFBundleURLSchemes</code>: </p> <pre class="prettyprint source lang-xml" ><code>&lt;key>CFBundleURLTypes&lt;/key> &lt;array> &lt;dict> &lt;key>CFBundleTypeRole&lt;/key> &lt;string>None&lt;/string> &lt;key>CFBundleURLName&lt;/key> &lt;string>auth0&lt;/string> &lt;key>CFBundleURLSchemes&lt;/key> &lt;array> &lt;string>$(PRODUCT_BUNDLE_IDENTIFIER)&lt;/string> &lt;/array> &lt;/dict> &lt;/array> </code></pre> <p> If your application is generated using the React Native CLI, the default value of <code>$(PRODUCT_BUNDLE_IDENTIFIER)</code> matches <code >org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</code >. Take note of this value as you'll be requiring it to define the callback URLs below. If desired, you can change its value using XCode in the following way: </p> <ul> <li> Open the <code>ios/TestApp.xcodeproj</code> file replacing 'TestApp' with the name of your app or run <code>xed ios</code> from a Terminal. </li> <li> Open your project's or desired target's <strong>Build Settings</strong> tab and on the search bar at the right type &quot;Product Bundle Identifier&quot;. </li> <li> Replace the <strong>Product Bundle Identifier</strong> value with your desired application's bundle identifier name (e.g. <code>com.example.app</code>). </li> <li> If you've changed the project wide settings, make sure the same were applied to each of the targets your app has. </li> </ul> <p> If you use a value other than <code>$(PRODUCT_BUNDLE_IDENTIFIER)</code> in the <code>CFBundleURLSchemes</code> field of the <code>Info.plist</code> you will also need to pass it as the <code>customScheme</code> option parameter of the <code>authorize</code> and <code>clearSession</code> methods. </p> <blockquote> <p> For more info please read the <a href="https://facebook.github.io/react-native/docs/linking.html" >React Native docs</a >. </p> </blockquote> <h3>Callback URL(s)</h3> <p> Callback URLs are the URLs that Auth0 invokes after the authentication process. Auth0 routes your application back to this URL and appends additional parameters to it, including a token. Since callback URLs can be manipulated, you will need to add this URL to your Application's <strong>Allowed Callback URLs</strong> for security. This will enable Auth0 to recognize these URLs as valid. If omitted, authentication will not be successful. </p> <p> On the Android platform this URL is case-sensitive. Because of that, this SDK will auto convert the Bundle Identifier (iOS) and Application ID (Android) values to lowercase in order to build the Callback URL with them. If any of these values contains uppercase characters a warning message will be printed in the console. Make sure to check that the right Callback URL is whitelisted in the Auth0 dashboard or the browser will not route succesfully back to your application. </p> <p> Go to the <a href="https://manage.auth0.com/#/applications">Auth0 Dashboard</a >, select your application and make sure that <strong>Allowed Callback URLs</strong> contains the URLs defined below. </p> <p> If in addition you plan to use the log out method, you must also add these URLs to the <strong>Allowed Logout URLs</strong>. </p> <h4>Android</h4> <pre class="prettyprint source lang-text" ><code>{YOUR_APP_PACKAGE_NAME_OR_CUSTOM_SCHEME}://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback </code></pre> <blockquote> <p> Make sure to replace {YOUR_APP_PACKAGE_NAME_OR_CUSTOM_SCHEME} and {YOUR_AUTH0_DOMAIN} with the actual values for your application. </p> </blockquote> <h4>iOS</h4> <pre class="prettyprint source lang-text" ><code>{YOUR_BUNDLE_IDENTIFIER_OR_CUSTOM_SCHEME}://{YOUR_AUTH0_DOMAIN}/ios/{YOUR_BUNDLE_IDENTIFIER}/callback </code></pre> <blockquote> <p> Make sure to replace {YOUR_BUNDLE_IDENTIFIER_OR_CUSTOM_SCHEME} and {YOUR_AUTH0_DOMAIN} with the actual values for your application. </p> </blockquote> <h2>Usage</h2> <p> Create a new instance of the client using the Auth0 domain and client ID values from your Application's <a href="https://manage.auth0.com/">dashboard page</a>. </p> <pre class="prettyprint source lang-js" ><code>import Auth0 from 'react-native-auth0'; const auth0 = new Auth0({ domain: '{YOUR_AUTH0_DOMAIN}', clientId: '{YOUR_CLIENT_ID}', }); </code></pre> <blockquote> <p> This SDK is OIDC compliant. To ensure OIDC compliant responses from the Auth0 servers enable the <strong>OIDC Conformant</strong> switch in your Auth0 dashboard under <code>Application / Settings / Advanced OAuth</code>. For more information please check <a href="https://auth0.com/docs/api-auth/intro#how-to-use-the-new-flows" >this documentation</a >. </p> </blockquote> <h3>Web Authentication</h3> <h4>Login</h4> <pre class="prettyprint source lang-js"><code>auth0.webAuth .authorize({scope: 'openid email profile'}) .then(credentials => console.log(credentials)) .catch(error => console.log(error)); </code></pre> <blockquote> <p> Web Authentication flows require a Browser application installed on the device. When no Browser is available, an error of type <code>a0.browser_not_available</code> will be raised via the provided callback. </p> </blockquote> <h5>Disable Single Sign On (iOS 13+ only)</h5> <p> Use the <code>ephemeralSession</code> parameter to disable SSO on iOS 13+. This way iOS will not display the consent popup that otherwise shows up when SSO is enabled. It has no effect on older versions of iOS or Android. </p> <pre class="prettyprint source lang-js"><code>auth0.webAuth .authorize({scope: 'openid email profile'}, {ephemeralSession: true}) .then(credentials => console.log(credentials)) .catch(error => console.log(error)); </code></pre> <h4>Logout</h4> <pre class="prettyprint source lang-js" ><code>auth0.webAuth.clearSession().catch(error => console.log(error)); </code></pre> <p> If you're using the <code>ephemeralSession</code> parameter, you do not need to call <code>clearSession()</code> to perform logout on iOS, as there will be no cookies to remove. Just deleting the credentials will suffice. You will still need to call <code>clearSession()</code> on Android, though, as <code>ephemeralSession</code> is iOS-only. </p> <h3>Authentication API</h3> <h3>Important: Database Connection Authentication</h3> <p> Since June 2017 new Clients no longer have the <strong>Password Grant Type</strong> enabled by default. If you are accessing a Database Connection using <code>passwordRealm</code> then you will need to enable the Password Grant Type, please follow <a href="https://auth0.com/docs/clients/client-grant-types#how-to-edit-the-client-grant_types-property" >this guide</a >. </p> <h4>Login with Password Realm Grant</h4> <pre class="prettyprint source lang-js"><code>auth0.auth .passwordRealm({ username: 'info@auth0.com', password: 'password', realm: 'myconnection', }) .then(console.log) .catch(console.error); </code></pre> <h4>Get user information using user's access_token</h4> <pre class="prettyprint source lang-js"><code>auth0.auth .userInfo({token: 'the user access_token'}) .then(console.log) .catch(console.error); </code></pre> <p> This endpoint requires an Access Token that was granted the <code>/userinfo</code> audience. Check that the authentication request that returned the Access Token included an audience value of <code>https://{YOUR_AUTH0_DOMAIN}.auth0.com/userinfo</code>. </p> <h4>Getting new access token with refresh token</h4> <pre class="prettyprint source lang-js"><code>auth0.auth .refreshToken({refreshToken: 'the user refresh_token'}) .then(console.log) .catch(console.error); </code></pre> <h4>Login with Passwordless</h4> <p> Passwordless is a two-step authentication flow that makes use of this type of connection. The <strong>Passwordless OTP</strong> grant is required to be enabled in your Auth0 application beforehand. Check <a href="https://auth0.com/docs/dashboard/guides/applications/update-grant-types" >our guide</a > to learn how to enable it. </p> <p> To start the flow, you request a code to be sent to the user's email or phone number. For email scenarios only, a link can be sent in place of the code. </p> <pre class="prettyprint source lang-js"><code>auth0.auth .passwordlessWithEmail({ email: 'info@auth0.com', send: 'link', }) .then(console.log) .catch(console.error); </code></pre> <p>or</p> <pre class="prettyprint source lang-js"><code>auth0.auth .passwordlessWithSMS({ phoneNumber: '+5491159991000', }) .then(console.log) .catch(console.error); </code></pre> <p> Then, in order to complete the authentication, you must send back that received code value along with the email or phone number used: </p> <pre class="prettyprint source lang-js"><code>auth0.auth .loginWithEmail({ email: 'info@auth0.com', code: '123456', }) .then(console.log) .catch(console.error); </code></pre> <p>or</p> <pre class="prettyprint source lang-js"><code>auth0.auth .loginWithSMS({ phoneNumber: 'info@auth0.com', code: '123456', }) .then(console.log) .catch(console.error); </code></pre> <h4>Create user in database connection</h4> <pre class="prettyprint source lang-js"><code>auth0.auth .createUser({ email: 'info@auth0.com', username: 'username', password: 'password', connection: 'myconnection', }) .then(console.log) .catch(console.error); </code></pre> <h3>Management API (Users)</h3> <h4>Patch user with user_metadata</h4> <pre class="prettyprint source lang-js"><code>auth0 .users('the user access_token') .patchUser({id: 'user_id', metadata: {first_name: 'John', last_name: 'Doe'}}) .then(console.log) .catch(console.error); </code></pre> <h3>Get full user profile</h3> <pre class="prettyprint source lang-js"><code>auth0 .users('the user access_token') .getUser({id: 'user_id'}) .then(console.log) .catch(console.error); </code></pre> <p> For more info please check our generated <a href="https://auth0.github.io/react-native-auth0/index.html" >documentation</a > </p> <h3>Organizations</h3> <p> <a href="https://auth0.com/docs/organizations">Organizations</a> is a set of features that provide better support for developers who build and maintain SaaS and Business-to-Business (B2B) applications. </p> <p>Using Organizations, you can:</p> <ul> <li> Represent teams, business customers, partner companies, or any logical grouping of users that should have different ways of accessing your applications, as organizations. </li> <li> Manage their membership in a variety of ways, including user invitation. </li> <li> Configure branded, federated login flows for each organization. </li> <li> Implement role-based access control, such that users can have different roles when authenticating in the context of different organizations. </li> <li> Build administration capabilities into your products, using Organizations APIs, so that those businesses can manage their own organizations. </li> </ul> <p> Note that Organizations is currently only available to customers on our Enterprise and Startup subscription plans. </p> <h4>Log in to an organization</h4> <pre class="prettyprint source lang-js"><code>auth0.webAuth .authorize({organization: 'organization-id'}) .then(credentials => console.log(credentials)) .catch(error => console.log(error)); </code></pre> <h4>Accept user invitations</h4> <p> Users can be invited to your organization via a link. Tapping on the invitation link should open your app. Since invitations links are <code>https</code> only, is recommended that your Android app supports <a href="https://developer.android.com/training/app-links" >Android App Links</a >. In the case of iOS, your app must support <a href="https://developer.apple.com/documentation/xcode/allowing_apps_and_websites_to_link_to_your_content/supporting_universal_links_in_your_app" >Universal Links</a >. </p> <p> In <a href="https://auth0.com/docs/applications/enable-android-app-links-support" >Enable Android App Links Support</a > and <a href="https://auth0.com/docs/enable-universal-links-support-in-apple-xcode" >Enable Universal Links Support</a >, you will find how to make the Auth0 server publish the Digital Asset Links file required by your applications. </p> <p> When your app gets opened by an invitation link, grab the invitation URL and pass it as a parameter to the webauth call. Use the <a href="https://reactnative.dev/docs/linking">Linking Module</a> method called <code>getInitialUrl()</code> to obtain the URL that launched your application. </p> <pre class="prettyprint source lang-js"><code>auth0.webAuth .authorize({ invitationUrl: 'https://myapp.com/login?invitation=inv123&organization=org123', }) .then(credentials => console.log(credentials)) .catch(error => console.log(error)); </code></pre> <p> If the URL doesn't contain the expected values, an error will be raised through the provided callback. </p> <h3>Bot Protection</h3> <p> If you are using the <a href="https://auth0.com/docs/anomaly-detection/bot-protection" >Bot Protection</a > feature and performing database login/signup via the Authentication API, you need to handle the <code>requires_verification</code> error. It indicates that the request was flagged as suspicious and an additional verification step is necessary to log the user in. That verification step is web-based, so you need to use Universal Login to complete it. </p> <pre class="prettyprint source lang-js" ><code>const email = 'support@auth0.com'; const realm = 'Username-Password-Authentication'; const scope = 'openid profile'; auth0.auth .passwordRealm({ username: email, password: 'secret-password', realm: realm, scope: scope, }) .then(credentials => { // Logged in! }) .catch(error => { if (error.name === 'requires_verification') { auth0.webAuth .authorize({ connection: realm, scope: scope, login_hint: email, // So the user doesn't have to type it again }) .then(credentials => { // Logged in! }) .catch(console.error); } else { console.error(error); } }); </code></pre> <p> In the case of signup, you can add <a href="https://auth0.com/docs/universal-login/new-experience#signup" >an additional parameter</a > to make the user land directly on the signup page: </p> <pre class="prettyprint source lang-js" ><code>auth0.webAuth.authorize({ connection: realm, scope: scope, login_hint: email, screen_hint: 'signup', // 👈🏻 }); </code></pre> <p> Check out how to set up Universal Login in the <a href="#getting-started">Getting Started</a> section. </p> <h2>Contributing</h2> <p> We appreciate feedback and contribution to this repo! Before you get started, please see the following: </p> <ul> <li> <a href="https://github.com/auth0/.github/blob/master/CONTRIBUTING.md" >Auth0's general contribution guidelines</a > </li> <li> <a href="https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md" >Auth0's code of conduct guidelines</a > </li> <li><a href="DEVELOPMENT.md">This repo's development guide</a></li> </ul> <h2>Support + Feedback</h2> <ul> <li> Use <a href="https://github.com/auth0/react-native-auth0/issues" >Issues</a > for code-level support </li> <li> Use <a href="https://community.auth0.com/">Community</a> for usage, questions, specific cases </li> </ul> <h2>Vulnerability Reporting</h2> <p> Please do not report security vulnerabilities on the public GitHub issue tracker. The <a href="https://auth0.com/responsible-disclosure-policy/" >Responsible Disclosure Program</a > details the procedure for disclosing security issues. </p> <h2>What is Auth0?</h2> <p>Auth0 helps you to easily:</p> <ul> <li> implement authentication with multiple identity providers, including social (e.g., Google, Facebook, Microsoft, LinkedIn, GitHub, Twitter, etc), or enterprise (e.g., Windows Azure AD, Google Apps, Active Directory, ADFS, SAML, etc.) </li> <li> log in users with username/password databases, passwordless, or multi-factor authentication </li> <li>link multiple user accounts together</li> <li> generate signed JSON Web Tokens to authorize your API calls and flow the user identity securely </li> <li> access demographics and analytics detailing how, when, and where users are logging in </li> <li> enrich user profiles from other data sources using customizable JavaScript rules </li> </ul> <p><a href="https://auth0.com/why-auth0">Why Auth0?</a></p> <h2>License</h2> <p> This project is licensed under the MIT license. See the <a href="LICENSE">LICENSE</a> file for more info. </p> <!-- Variables --> </article> </section> </div> <br class="clear" /> <footer> Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.6</a> on Tue Jun 22 2021 14:24:13 GMT-0300 (Argentina Standard Time) using the Minami theme. </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"></script> </body> </html>