+
+
Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout Why Auth0?
++This project is licensed under the MIT license. See the LICENSE file for more info.
+ + + +[npm-image]: https://img.shields.io/npm/v/react-native-auth0.svg?style=flat-square +[npm-url]: https://npmjs.org/package/react-native-auth0 +[circleci-image]: https://img.shields.io/circleci/project/github/auth0/react-native-auth0.svg?branch=master&style=flat-square +[circleci-url]: https://circleci.com/gh/auth0/react-native-auth0 +[codecov-image]: https://img.shields.io/codecov/c/github/auth0/react-native-auth0.svg?style=flat-square +[codecov-url]: https://codecov.io/github/auth0/react-native-auth0 +[license-image]: https://img.shields.io/npm/l/react-native-auth0.svg?style=flat-square +[license-url]: #license +[downloads-image]: https://img.shields.io/npm/dm/react-native-auth0.svg?style=flat-square +[downloads-url]: https://npmjs.org/package/react-native-auth0 diff --git a/docs/Types/README.md b/docs/Types/README.md new file mode 100644 index 00000000..07b90966 --- /dev/null +++ b/docs/Types/README.md @@ -0,0 +1,25 @@ +[**react-native-auth0**](../README.md) + +--- + +[react-native-auth0](../globals.md) / Types + +# Types + +## Classes + +- [Auth](classes/Auth.md) +- [BaseError](classes/BaseError.md) +- [CredentialsManager](classes/CredentialsManager.md) +- [Users](classes/Users.md) +- [WebAuth](classes/WebAuth.md) + +## Interfaces + +- [Auth0ContextInterface](interfaces/Auth0ContextInterface.md) +- [AuthState](interfaces/AuthState.md) + +## Type Aliases + +- [Auth0Response](type-aliases/Auth0Response.md) +- [Telemetry](type-aliases/Telemetry.md) diff --git a/docs/Types/classes/Auth.md b/docs/Types/classes/Auth.md new file mode 100644 index 00000000..ff7d9d39 --- /dev/null +++ b/docs/Types/classes/Auth.md @@ -0,0 +1,463 @@ +[**react-native-auth0**](../../README.md) + +--- + +[react-native-auth0](../../globals.md) / [Types](../README.md) / Auth + +# Class: Auth + +Defined in: [auth/index.ts:65](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L65) + +Class for interfacing with the Auth0 Authentication API endpoints. + +## See + +https://auth0.com/docs/api/authentication + +## Properties + +### clientId + +> `readonly` **clientId**: `string` + +Defined in: [auth/index.ts:70](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L70) + +The Auth0 client ID + +--- + +### domain + +> `readonly` **domain**: `string` + +Defined in: [auth/index.ts:74](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L74) + +The Auth0 tenant domain + +## Methods + +### authorizeUrl() + +> **authorizeUrl**(`parameters`): `string` + +Defined in: [auth/index.ts:104](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L104) + +Builds the full authorize endpoint url in the Authorization Server (AS) with given parameters. + +#### Parameters + +##### parameters + +[`AuthorizeUrlOptions`](../../interfaces/AuthorizeUrlOptions.md) + +#### Returns + +`string` + +A URL to the authorize endpoint with specified parameters to redirect to for AuthZ/AuthN. + +#### See + +https://auth0.com/docs/api/authentication#authorize-client + +--- + +### createUser() + +> **createUser**(`parameters`): `Promise`\<`Partial`\<[`User`](../../type-aliases/User.md)\>\> + +Defined in: [auth/index.ts:585](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L585) + +Creates a new user using the options provided. + +#### Parameters + +##### parameters + +[`CreateUserOptions`](../../interfaces/CreateUserOptions.md) + +#### Returns + +`Promise`\<`Partial`\<[`User`](../../type-aliases/User.md)\>\> + +An instance of [User](../../type-aliases/User.md). + +--- + +### exchange() + +> **exchange**(`parameters`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [auth/index.ts:149](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L149) + +Exchanges a code obtained via `/authorize` (w/PKCE) for the user's tokens + +#### Parameters + +##### parameters + +[`ExchangeOptions`](../../interfaces/ExchangeOptions.md) + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A prominse for a populated instance of [Credentials](../../type-aliases/Credentials.md). + +#### See + +https://auth0.com/docs/api-auth/grant/authorization-code-pkce + +--- + +### exchangeNativeSocial() + +> **exchangeNativeSocial**(`parameters`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [auth/index.ts:179](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L179) + +Exchanges an external token obtained via a native social authentication solution for the user's tokens + +#### Parameters + +##### parameters + +[`ExchangeNativeSocialOptions`](../../interfaces/ExchangeNativeSocialOptions.md) + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A populated instance of [Credentials](../../type-aliases/Credentials.md). + +#### See + +https://auth0.com/docs/api/authentication#token-exchange-for-native-social + +--- + +### loginWithEmail() + +> **loginWithEmail**(`parameters`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [auth/index.ts:305](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L305) + +Completes the Passworldess authentication with an email connection that was started using [passwordlessWithEmail](#passwordlesswithemail). + +#### Parameters + +##### parameters + +[`LoginWithEmailOptions`](../../interfaces/LoginWithEmailOptions.md) + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A populated instance of [Credentials](../../type-aliases/Credentials.md). + +--- + +### loginWithOOB() + +> **loginWithOOB**(`parameters`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [auth/index.ts:406](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L406) + +Log in a user using an Out Of Band authentication code after they have received the 'mfa_required' error. +The MFA token tells the server the username or email, password, and realm values sent on the first request. + +Requires your client to have the **MFA OOB** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types) to learn how to enable it. + +#### Parameters + +##### parameters + +[`LoginWithOOBOptions`](../../interfaces/LoginWithOOBOptions.md) + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A populated instance of [Credentials](../../type-aliases/Credentials.md). + +--- + +### loginWithOTP() + +> **loginWithOTP**(`parameters`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [auth/index.ts:373](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L373) + +Log in a user using the One Time Password code after they have received the 'mfa_required' error. +The MFA token tells the server the username or email, password, and realm values sent on the first request. + +Requires your client to have the **MFA OTP** Grant Type enabled. +See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types) to learn how to enable it. + +#### Parameters + +##### parameters + +[`LoginWithOTPOptions`](../../interfaces/LoginWithOTPOptions.md) + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A populated instance of [Credentials](../../type-aliases/Credentials.md). + +--- + +### loginWithRecoveryCode() + +> **loginWithRecoveryCode**(`parameters`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [auth/index.ts:440](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L440) + +Log in a user using a multi-factor authentication Recovery Code after they have received the 'mfa_required' error. +The MFA token tells the server the username or email, password, and realm values sent on the first request. + +Requires your client to have the **MFA** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types) to learn how to enable it. + +#### Parameters + +##### parameters + +[`LoginWithRecoveryCodeOptions`](../../interfaces/LoginWithRecoveryCodeOptions.md) + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A populated instance of [Credentials](../../type-aliases/Credentials.md). + +--- + +### loginWithSMS() + +> **loginWithSMS**(`parameters`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [auth/index.ts:337](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L337) + +Completes the Passworldess authentication with an SMS connection that was started using [passwordlessWithSMS](#passwordlesswithsms). + +#### Parameters + +##### parameters + +[`LoginWithSMSOptions`](../../interfaces/LoginWithSMSOptions.md) + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A populated instance of [Credentials](../../type-aliases/Credentials.md). + +--- + +### logoutUrl() + +> **logoutUrl**(`parameters`): `string` + +Defined in: [auth/index.ts:129](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L129) + +Builds the full logout endpoint url in the Authorization Server (AS) with given parameters. + +#### Parameters + +##### parameters + +[`LogoutUrlOptions`](../../interfaces/LogoutUrlOptions.md) + +#### Returns + +`string` + +A URL to the logout endpoint with specified parameters + +#### See + +https://auth0.com/docs/api/authentication#logout + +--- + +### multifactorChallenge() + +> **multifactorChallenge**(`parameters`): `Promise`\<[`MultifactorChallengeResponse`](../../type-aliases/MultifactorChallengeResponse.md)\> + +Defined in: [auth/index.ts:474](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L474) + +Request a challenge for multi-factor authentication (MFA) based on the challenge types supported by the application and user. +The challenge type is how the user will get the challenge and prove possession. Supported challenge types include: "otp" and "oob". + +#### Parameters + +##### parameters + +[`MultifactorChallengeOptions`](../../interfaces/MultifactorChallengeOptions.md) + +#### Returns + +`Promise`\<[`MultifactorChallengeResponse`](../../type-aliases/MultifactorChallengeResponse.md)\> + +[MultifactorChallengeOTPResponse](../../type-aliases/MultifactorChallengeOTPResponse.md), [MultifactorChallengeOOBResponse](../../type-aliases/MultifactorChallengeOOBResponse.md), or [MultifactorChallengeOOBWithBindingResponse](../../type-aliases/MultifactorChallengeOOBWithBindingResponse.md) depending +on the challenge type. + +--- + +### passwordlessWithEmail() + +> **passwordlessWithEmail**(`parameters`): `Promise`\<`void`\> + +Defined in: [auth/index.ts:262](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L262) + +Starts the Passworldess flow with an email connection. + +This should be completed later using a call to [loginWithEmail](#loginwithemail), passing the OTP that was sent to the user. + +#### Parameters + +##### parameters + +[`PasswordlessWithEmailOptions`](../../interfaces/PasswordlessWithEmailOptions.md) + +#### Returns + +`Promise`\<`void`\> + +--- + +### passwordlessWithSMS() + +> **passwordlessWithSMS**(`parameters`): `Promise`\<`void`\> + +Defined in: [auth/index.ts:279](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L279) + +Starts the Passwordless flow with an SMS connection. + +This should be completed later using a call to [loginWithSMS](#loginwithsms), passing the OTP that was sent to the user. + +#### Parameters + +##### parameters + +[`PasswordlessWithSMSOptions`](../../interfaces/PasswordlessWithSMSOptions.md) + +#### Returns + +`Promise`\<`void`\> + +--- + +### passwordRealm() + +> **passwordRealm**(`parameters`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [auth/index.ts:213](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L213) + +Performs Auth with user credentials using the Password Realm Grant + +#### Parameters + +##### parameters + +[`PasswordRealmOptions`](../../interfaces/PasswordRealmOptions.md) + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A populated instance of [Credentials](../../type-aliases/Credentials.md). + +#### See + +https://auth0.com/docs/api-auth/grant/password#realm-support + +--- + +### refreshToken() + +> **refreshToken**(`parameters`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [auth/index.ts:233](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L233) + +Obtain new tokens using the Refresh Token obtained during Auth (requesting `offline_access` scope) + +#### Parameters + +##### parameters + +[`RefreshTokenOptions`](../../interfaces/RefreshTokenOptions.md) + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A populated instance of [Credentials](../../type-aliases/Credentials.md). + +#### See + +https://auth0.com/docs/tokens/refresh-token/current#use-a-refresh-token + +--- + +### resetPassword() + +> **resetPassword**(`parameters`): `Promise`\<`void`\> + +Defined in: [auth/index.ts:566](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L566) + +Request an email with instructions to change password of a user + +#### Parameters + +##### parameters + +[`ResetPasswordOptions`](../../interfaces/ResetPasswordOptions.md) + +#### Returns + +`Promise`\<`void`\> + +--- + +### revoke() + +> **revoke**(`parameters`): `Promise`\<`void`\> + +Defined in: [auth/index.ts:503](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L503) + +Revoke an issued refresh token + +#### Parameters + +##### parameters + +[`RevokeOptions`](../../interfaces/RevokeOptions.md) + +#### Returns + +`Promise`\<`void`\> + +--- + +### userInfo() + +> **userInfo**(`parameters`): `Promise`\<[`User`](../../type-aliases/User.md)\> + +Defined in: [auth/index.ts:530](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/auth/index.ts#L530) + +Return user information using an access token + +#### Parameters + +##### parameters + +[`UserInfoOptions`](../../interfaces/UserInfoOptions.md) + +#### Returns + +`Promise`\<[`User`](../../type-aliases/User.md)\> + +The user's profile information. diff --git a/docs/Types/classes/BaseError.md b/docs/Types/classes/BaseError.md new file mode 100644 index 00000000..b4368bea --- /dev/null +++ b/docs/Types/classes/BaseError.md @@ -0,0 +1,55 @@ +[**react-native-auth0**](../../README.md) + +--- + +[react-native-auth0](../../globals.md) / [Types](../README.md) / BaseError + +# Class: BaseError + +Defined in: [utils/baseError.ts:1](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/utils/baseError.ts#L1) + +## Extends + +- `Error` + +## Extended by + +- [`TimeoutError`](../../classes/TimeoutError.md) + +## Constructors + +### Constructor + +> **new BaseError**(`name`, `message`, `type?`): `BaseError` + +Defined in: [utils/baseError.ts:3](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/utils/baseError.ts#L3) + +#### Parameters + +##### name + +`string` + +##### message + +`string` + +##### type? + +`string` + +#### Returns + +`BaseError` + +#### Overrides + +`Error.constructor` + +## Properties + +### type + +> **type**: `string` + +Defined in: [utils/baseError.ts:2](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/utils/baseError.ts#L2) diff --git a/docs/Types/classes/CredentialsManager.md b/docs/Types/classes/CredentialsManager.md new file mode 100644 index 00000000..8a126b64 --- /dev/null +++ b/docs/Types/classes/CredentialsManager.md @@ -0,0 +1,109 @@ +[**react-native-auth0**](../../README.md) + +--- + +[react-native-auth0](../../globals.md) / [Types](../README.md) / CredentialsManager + +# Class: CredentialsManager + +Defined in: [credentials-manager/index.ts:8](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/credentials-manager/index.ts#L8) + +## Methods + +### clearCredentials() + +> **clearCredentials**(): `Promise`\<`void`\> + +Defined in: [credentials-manager/index.ts:123](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/credentials-manager/index.ts#L123) + +Delete the stored credentials + +#### Returns + +`Promise`\<`void`\> + +--- + +### getCredentials() + +> **getCredentials**(`scope?`, `minTtl?`, `parameters?`, `forceRefresh?`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [credentials-manager/index.ts:70](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/credentials-manager/index.ts#L70) + +Gets the credentials that has already been saved + +#### Parameters + +##### scope? + +`string` + +The scope to request for the access token. If null is passed, the previous scope will be kept. + +##### minTtl? + +`number` = `0` + +The minimum time in seconds that the access token should last before expiration. + +##### parameters? + +`Record`\<`string`, `unknown`\> = `{}` + +Additional parameters to send in the request to refresh expired credentials. + +##### forceRefresh? + +`boolean` = `false` + +Whether to force refresh the credentials. It will work only if the refresh token already exists. For iOS, doing forceRefresh will not send the scope. Since scope change already does force refresh, it is better to avoid force refresh if the scope is being changed. + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A populated instance of [Credentials](../../type-aliases/Credentials.md). + +--- + +### hasValidCredentials() + +> **hasValidCredentials**(`minTtl`): `Promise`\<`boolean`\> + +Defined in: [credentials-manager/index.ts:110](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/credentials-manager/index.ts#L110) + +Returns whether this manager contains a valid non-expired pair of credentials. + +#### Parameters + +##### minTtl + +`number` = `0` + +The minimum time in seconds that the access token should last before expiration + +#### Returns + +`Promise`\<`boolean`\> + +`true` if a valid set of credentials are available, or `false` if there are no credentials to return. + +--- + +### saveCredentials() + +> **saveCredentials**(`credentials`): `Promise`\<`void`\> + +Defined in: [credentials-manager/index.ts:31](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/credentials-manager/index.ts#L31) + +Saves the provided credentials + +#### Parameters + +##### credentials + +[`Credentials`](../../type-aliases/Credentials.md) + +#### Returns + +`Promise`\<`void`\> diff --git a/docs/Types/classes/Users.md b/docs/Types/classes/Users.md new file mode 100644 index 00000000..923d25c8 --- /dev/null +++ b/docs/Types/classes/Users.md @@ -0,0 +1,78 @@ +[**react-native-auth0**](../../README.md) + +--- + +[react-native-auth0](../../globals.md) / [Types](../README.md) / Users + +# Class: Users + +Defined in: [management/users.ts:39](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/management/users.ts#L39) + +Auth0 Management API User endpoints + +## Export + +## See + +https://auth0.com/docs/api/management/v2#!/Users/ +Users + +## Methods + +### getUser() + +> **getUser**(`parameters`): `Promise`\<[`User`](../../type-aliases/User.md)\> + +Defined in: [management/users.ts:67](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/management/users.ts#L67) + +Returns the user by identifier + +#### Parameters + +##### parameters + +[`GetUserOptions`](../../interfaces/GetUserOptions.md) + +get user by identifier parameters + +#### Returns + +`Promise`\<[`User`](../../type-aliases/User.md)\> + +#### See + +https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id + +#### Memberof + +Users + +--- + +### patchUser() + +> **patchUser**(`parameters`): `Promise`\<[`User`](../../type-aliases/User.md)\> + +Defined in: [management/users.ts:90](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/management/users.ts#L90) + +Patch a user's `user_metadata` + +#### Parameters + +##### parameters + +[`PatchUserOptions`](../../interfaces/PatchUserOptions.md) + +patch user metadata parameters + +#### Returns + +`Promise`\<[`User`](../../type-aliases/User.md)\> + +#### See + +https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id + +#### Memberof + +Users diff --git a/docs/Types/classes/WebAuth.md b/docs/Types/classes/WebAuth.md new file mode 100644 index 00000000..fea70ee0 --- /dev/null +++ b/docs/Types/classes/WebAuth.md @@ -0,0 +1,95 @@ +[**react-native-auth0**](../../README.md) + +--- + +[react-native-auth0](../../globals.md) / [Types](../README.md) / WebAuth + +# Class: WebAuth + +Defined in: [webauth/index.ts:24](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/webauth/index.ts#L24) + +Helper to perform Auth against Auth0 hosted login page + +It will use `/authorize` endpoint of the Authorization Server (AS) +with Code Grant and Proof Key for Challenge Exchange (PKCE). + +## See + +https://auth0.com/docs/api-auth/grant/authorization-code-pkce + +## Methods + +### authorize() + +> **authorize**(`parameters`, `options`): `Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +Defined in: [webauth/index.ts:53](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/webauth/index.ts#L53) + +Starts the AuthN/AuthZ transaction against the AS in the in-app browser. + +To learn more about how to customize the authorize call, check the Universal Login Page +article at https://auth0.com/docs/hosted-pages/login + +#### Parameters + +##### parameters + +[`WebAuthorizeParameters`](../../interfaces/WebAuthorizeParameters.md) = `{}` + +##### options + +[`WebAuthorizeOptions`](../../interfaces/WebAuthorizeOptions.md) = `{}` + +#### Returns + +`Promise`\<[`Credentials`](../../type-aliases/Credentials.md)\> + +A poplulated instance of [Credentials](../../type-aliases/Credentials.md). + +#### See + +https://auth0.com/docs/api/authentication#authorize-client + +--- + +### cancelWebAuth() + +> **cancelWebAuth**(): `Promise`\<`void`\> + +Defined in: [webauth/index.ts:79](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/webauth/index.ts#L79) + +Terminates the ongoing web-based operation and reports back that it was cancelled. +You need to call this method within your custom Web Auth provider implementation whenever the operation is +cancelled by the user. + +#### Returns + +`Promise`\<`void`\> + +--- + +### clearSession() + +> **clearSession**(`parameters`, `options`): `Promise`\<`void`\> + +Defined in: [webauth/index.ts:92](https://github.com/auth0/react-native-auth0/blob/64b3136e2ba68da80f979438fc7bc3abab9becdd/src/webauth/index.ts#L92) + +Removes Auth0 session and optionally remove the Identity Provider session. + +#### Parameters + +##### parameters + +[`ClearSessionParameters`](../../interfaces/ClearSessionParameters.md) = `{}` + +##### options + +[`ClearSessionOptions`](../../interfaces/ClearSessionOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### See + +https://auth0.com/docs/logout diff --git a/docs/Types/interfaces/Auth0ContextInterface.md b/docs/Types/interfaces/Auth0ContextInterface.md new file mode 100644 index 00000000..6f1f71a1 --- /dev/null +++ b/docs/Types/interfaces/Auth0ContextInterface.md @@ -0,0 +1,451 @@ +[**react-native-auth0**](../../README.md) + +--- + +[react-native-auth0](../../globals.md) / [Types](../README.md) / Auth0ContextInterface + +# Interface: Auth0ContextInterface\Private
- client
- Readonly
- clientThe Auth0 client ID
-Readonly
- domain
- The Auth0 tenant domain
-- Builds the full authorize endpoint url in the Authorization - Server (AS) with given parameters. -
-- A URL to the authorize endpoint with specified parameters to - redirect to for AuthZ/AuthN. -
- - -Creates a new user using the options provided.
-- An instance of - User. -
- - -
- Exchanges a code obtained via
- /authorize (w/PKCE) for the user's tokens
-
- A prominse for a populated instance of - Credentials. -
- - -- Exchanges an external token obtained via a native social - authentication solution for the user's tokens -
-- A populated instance of - Credentials. -
- - -- Completes the Passworldess authentication with an email - connection that was started using - passwordlessWithEmail. -
-- A populated instance of - Credentials. -
- - -- Log in a user using an Out Of Band authentication code after - they have received the 'mfa_required' error. The MFA - token tells the server the username or email, password, and - realm values sent on the first request. -
-- Requires your client to have the - MFA OOB Grant Type enabled. See - Client Grant Types - to learn how to enable it. -
-- A populated instance of - Credentials. -
- - -- Log in a user using the One Time Password code after they - have received the 'mfa_required' error. The MFA - token tells the server the username or email, password, and - realm values sent on the first request. -
-- Requires your client to have the - MFA OTP Grant Type enabled. See - Client Grant Types - to learn how to enable it. -
-- A populated instance of - Credentials. -
- - -- Log in a user using a multi-factor authentication Recovery - Code after they have received the 'mfa_required' - error. The MFA token tells the server the username or email, - password, and realm values sent on the first request. -
-- Requires your client to have the MFA Grant - Type enabled. See - Client Grant Types - to learn how to enable it. -
-- A populated instance of - Credentials. -
- - -- Completes the Passworldess authentication with an SMS - connection that was started using - passwordlessWithSMS. -
-- A populated instance of - Credentials. -
- - -- Builds the full logout endpoint url in the Authorization - Server (AS) with given parameters. -
-A URL to the logout endpoint with specified parameters
-- Request a challenge for multi-factor authentication (MFA) - based on the challenge types supported by the application - and user. The challenge type is how the user will get the - challenge and prove possession. Supported challenge types - include: "otp" and "oob". -
-- MultifactorChallengeOTPResponse, - MultifactorChallengeOOBResponse, or - MultifactorChallengeOOBWithBindingResponse - depending on the challenge type. -
- - -- Performs Auth with user credentials using the Password Realm - Grant -
-- A populated instance of - Credentials. -
- - -Starts the Passworldess flow with an email connection.
-- This should be completed later using a call to - loginWithEmail, passing the OTP that was sent to the user. -
-Starts the Passwordless flow with an SMS connection.
-- This should be completed later using a call to - loginWithSMS, passing the OTP that was sent to the user. -
-
- Obtain new tokens using the Refresh Token obtained during
- Auth (requesting offline_access scope)
-
- A populated instance of - Credentials. -
- - -- Request an email with instructions to change password of a - user -
-Revoke an issued refresh token
-Return user information using an access token
-The user's profile information.
- - -Private
- Auth0Private
- clientPrivate
- domain
- Private
- Optional
- localGets the credentials that has already been saved
-Optional
- scope:
- string
- - The scope to request for the access token. If null is - passed, the previous scope will be kept. -
-- The minimum time in seconds that the access token - should last before expiration. -
-- Additional parameters to send in the request to - refresh expired credentials. -
-- Whether to force refresh the credentials. It will work - only if the refresh token already exists. For iOS, - doing forceRefresh will not send the scope. Since - scope change already does force refresh, it is better - to avoid force refresh if the scope is being changed. -
-- A populated instance of - Credentials. -
- - -- Returns whether this manager contains a valid non-expired - pair of credentials. -
-- The minimum time in seconds that the access token - should last before expiration -
-
- true if a valid set of credentials are available,
- or false if there are no credentials to return.
-
Saves the provided credentials
-Auth0 Management API User endpoints
-Private
- client
- Returns the user by identifier
-get user by identifier parameters
-Patch a user's user_metadata
patch user metadata parameters
-Helper to perform Auth against Auth0 hosted login page
-
- It will use /authorize endpoint of the Authorization
- Server (AS) with Code Grant and Proof Key for Challenge Exchange
- (PKCE).
-
Private
- agent
- Private
- clientPrivate
- domain
- Private
- Optional
- local- Starts the AuthN/AuthZ transaction against the AS in the - in-app browser. -
-- To learn more about how to customize the authorize call, - check the Universal Login Page article at - https://auth0.com/docs/hosted-pages/login -
-- A poplulated instance of - Credentials. -
- - -- Terminates the ongoing web-based operation and reports back - that it was cancelled. You need to call this method within - your custom Web Auth provider implementation whenever the - operation is cancelled by the user. -
-- Removes Auth0 session and optionally remove the Identity - Provider session. -
-Auth0 for React Native client
-Creates an instance of Auth0.
-Your Auth0 application information
-Your Auth0 application client identifier
-Your Auth0 domain
-Optional
- local- The options for configuring the display of local - authentication prompt, authentication level - (Android only) and evaluation policy (iOS only). -
-Optional
- telemetry?: Telemetry
- - The telemetry information to be sent along with - the requests -
-Optional
- timeout?: number
- Timeout to be set for requests.
-Optional
- token?: string
- Token to be used for Management APIs
-Private
- options
- Optional
- localOptional
- telemetry?: Telemetry
- Optional
- timeout?: number
- Optional
- token?: string
- - Used for Android only: The level of local - authentication required to access the credentials. Defaults to - LocalAuthenticationLevel.strong. -
-- The non-biometric credential used to secure the device (i. e. - PIN, pattern, or password). -
-- Any biometric (e.g. fingerprint, iris, or face) on the device - that meets or exceeds the requirements for Class 3 (formerly - Strong), as defined by the Android CDD. -
-- Any biometric (e.g. fingerprint, iris, or face) on the device - that meets or exceeds the requirements for Class 2 (formerly - Weak), as defined by the Android CDD. -
-- Used for iOS only: The evaluation policy to use - when accessing the credentials. Defaults to - LocalAuthenticationStrategy.deviceOwnerWithBiometrics. -
-- User authentication with biometry, Apple Watch, or the device - passcode. -
-User authentication with biometry.
-- Presentation styles for when using SFSafariViewController on iOS. - For the full description of what each option does, please see - https://developer.apple.com/documentation/uikit/uimodalpresentationstyle - for more details -
-Provides the Auth0Context to its child components.
-<Auth0Provider domain="YOUR AUTH0 DOMAIN" clientId="YOUR CLIENT ID">
<App />
</Auth0Provider>
-
-
- Use the useAuth0 in your function components to
- access authentication state and methods.
-
The useAuth0 hook interface
-const {
// State
error,
user,
isLoading,
// Methods
authorize,
sendSMSCode,
authorizeWithSMS,
sendEmailCode,
authorizeWithEmail,
sendMultifactorChallenge,
authorizeWithOOB,
authorizeWithOTP,
authorizeWithRecoveryCode,
hasValidCredentials,
clearSession,
getCredentials,
clearCredentials,
requireLocalAuthentication,
authorizeWithPasswordRealm,
authorizeWithExchangeNativeSocial,
revokeRefreshToken
} = useAuth0();
-
- - Refer to - Auth0ContextInterface - on how to use the above methods. -
- - -
-
-
- 📚 Documentation • 🚀 - Getting Started • ⏭️ - Next Steps • ❓ - FAQs - • ❓ Feedback -
- -
- We're excited to announce the release of react-native-auth0
- v4.0.0! Please note that this update includes breaking
- changes that require your attention. To ensure a smooth transition,
- please review our 👉
- Migration Guide
- 👈 for detailed instructions on updating your integration.
-
- This SDK targets apps that are using React Native SDK version
- 0.65.0 and up. If you're using an older React
- Native version, see the compatibility matrix below.
-
- The following shows platform minimums for running projects with this - SDK: -
-| Platform | -Minimum version | -
|---|---|
| iOS | -13.0 | -
| Android | -34 | -
- Our SDK requires a minimum iOS deployment target of 13.0. In your - project's ios/Podfile, ensure your platform target is set to - 13.0. -
-platform :ios, '13.0'
-
-
- First install the native library module:
- -$ npm install react-native-auth0 --save
$ yarn add react-native-auth0
- Then, you need to run the following command to install the ios app - pods with Cocoapods. That will auto-link the iOS library: -
-$ cd ios && pod install
- You need to make your Android, iOS or Expo 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. -
- ---- 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
-singleTask- launchMode in that activity. To migrate your app - to version 2.9.0+, remove both and continue with - the instructions below. You can also check out a sample migration - diff - here. -
- Open your app's build.gradle file (typically at
- android/app/build.gradle) and add the following
- manifest placeholders:
-
android {
defaultConfig {
// Add the next line
manifestPlaceholders = [auth0Domain: "YOUR_AUTH0_DOMAIN", auth0Scheme: "${applicationId}.auth0"]
}
...
}
-
-
- The auth0Domain value must be replaced with your Auth0
- domain value. So if you have samples.us.auth0.com as
- your Auth0 domain you would have a configuration like the following:
-
android {
defaultConfig {
manifestPlaceholders = [auth0Domain: "samples.us.auth0.com", auth0Scheme: "${applicationId}.auth0"]
}
...
}
-
-
- The applicationId value will be auto-replaced at
- runtime with the package name or ID of your application (e.g.
- com.example.app). You can change this value from the
- build.gradle file. You can also check it at the top of
- your AndroidManifest.xml file.
-
--- Note that if your Android application is using - product flavors, you might need to specify different manifest placeholders for - each flavor. -
-
- If you use a value other than applicationId in
- auth0Scheme you will also need to pass it as the
- customScheme option parameter of the
- authorize and clearSession methods.
-
- Take note of this value as you'll be requiring it to define the - callback URLs below. -
--- -- For more info please read the - React Native docs. -
-
- If you don't plan to use Web Authentication, you will notice
- that the compiler will still prompt you to provide the
- manifestPlaceholders values, since the
- RedirectActivity included in this library will require
- them, and the Gradle tasks won't be able to run without them.
-
- Re-declare the activity manually with
- tools:node="remove" in your app's Android
- Manifest in order to make the manifest merger remove it from the
- final manifest file. Additionally, one more unused activity can be
- removed from the final APK by using the same process. A complete
- snippet to achieve this is:
-
<activity
android:name="com.auth0.android.provider.AuthenticationActivity"
tools:node="remove"/>
<!-- Optional: Remove RedirectActivity -->
<activity
android:name="com.auth0.android.provider.RedirectActivity"
tools:node="remove"/>
-
-
-
- Inside the ios folder find the file
- AppDelegate.[swift|m] add the following to it:
-
#import <React/RCTLinkingManager.h>
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
{
return [RCTLinkingManager application:app openURL:url options:options];
}
-
-
- Inside the ios folder open the
- Info.plist and locate the value for
- CFBundleIdentifier, e.g.
-
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
-
-
- and then below it register a URL type entry using the value of
- CFBundleIdentifier as the value for
- CFBundleURLSchemes:
-
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>None</string>
<key>CFBundleURLName</key>
<string>auth0</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).auth0</string>
</array>
</dict>
</array>
-
-
- If your application is generated using the React Native CLI, the
- default value of $(PRODUCT_BUNDLE_IDENTIFIER) matches
- org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier). 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:
-
ios/TestApp.xcodeproj file replacing
- 'TestApp' with the name of your app or run
- xed ios from a Terminal.
- com.example.app).
-
- If you use a value other than
- $(PRODUCT_BUNDLE_IDENTIFIER) in the
- CFBundleURLSchemes field of the
- Info.plist you will also need to pass it as the
- customScheme option parameter of the
- authorize and clearSession methods.
-
-- -- For more info please read the - React Native docs. -
-
--- :warning: This SDK is not compatible with "Expo Go" app - because of custom native code. It is compatible with Custom Dev - Client and EAS builds -
-
- To use the SDK with Expo, configure the app at build time by
- providing the domain and the
- customScheme values through the
- Config Plugin. To do this, add the following snippet to app.json or
- app.config.js:
-
{
"expo": {
...
"plugins": [
[
"react-native-auth0",
{
"domain": "YOUR_AUTH0_DOMAIN",
"customScheme": "YOUR_CUSTOM_SCHEME"
}
]
]
}
}
-
- --- :info: If you want to switch between multiple domains in your app, - refer - here -
-
| API | -Description | -
|---|---|
| domain | -- Mandatory: Provide the Auth0 domain that can be found at the - Application Settings - | -
| customScheme | -
- Optional: Custom scheme to build the callback URL with. The
- value provided here should be passed to the
- customScheme option parameter of the
- authorize and clearSession methods.
- The custom scheme should be a unique, all lowercase value with
- no special characters.
- |
-
- Now you can run the application using
- expo run:android or expo run:ios.
-
- 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 - Allowed Callback URLs for security. This will - enable Auth0 to recognize these URLs as valid. If omitted, - authentication will not be successful. -
-- 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 successfully back to - your application. -
-- Go to the - Auth0 Dashboard, select your application and make sure that - Allowed Callback URLs contains the URLs defined - below. -
-- If in addition you plan to use the log out method, you must also add - these URLs to the Allowed Logout URLs. -
- -{YOUR_APP_PACKAGE_NAME}.auth0://{AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
-
- -- -- Make sure to replace {YOUR_APP_PACKAGE_NAME} and {AUTH0_DOMAIN} - with the actual values for your application. The - {YOUR_APP_PACKAGE_NAME} value provided should be all lower case. -
-
{PRODUCT_BUNDLE_IDENTIFIER}.auth0://{AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
-
- -- -- Make sure to replace {PRODUCT_BUNDLE_IDENTIFIER} and - {AUTH0_DOMAIN} with the actual values for your application. The - {PRODUCT_BUNDLE_IDENTIFIER} value provided should be all lower - case. -
-
-- -- This SDK is OIDC compliant. To ensure OIDC compliant responses - from the Auth0 servers enable the - OIDC Conformant switch in your Auth0 dashboard - under
-Application / Settings / Advanced OAuth. For - more information please check - this documentation. -
- The SDK exports a React hook as the primary interface for performing - web authentication through the - browser using Auth0 - Universal Login. -
-
- Use the methods from the useAuth0 hook to implement
- login, logout, and to retrieve details about the authenticated user.
-
- See the
- API Documentation
- for full details on the useAuth0 hook.
-
- First, import the Auth0Provider component and wrap it
- around your application. Provide the domain and
- clientId values as given to you when setting up your
- Auth0 app in the dashboard:
-
import { Auth0Provider } from 'react-native-auth0';
const App = () => {
return (
<Auth0Provider domain="YOUR_AUTH0_DOMAIN" clientId="YOUR_AUTH0_CLIENT_ID">
{/* YOUR APP */}
</Auth0Provider>
);
};
export default App;
-
-
- If you're not using React Hooks, you can simply instantiate
- the Auth0 class:
-
import Auth0 from 'react-native-auth0';
const auth0 = new Auth0({
domain: 'YOUR_AUTH0_DOMAIN',
clientId: 'YOUR_AUTH0_CLIENT_ID',
});
-
- - Then import the hook into a component where you want to get access - to the properties and methods for integrating with Auth0: -
-import { useAuth0 } from 'react-native-auth0';
-
-
-
- Use the authorize method to redirect the user to the
- Auth0
- Universal Login
- page for authentication. If scope is not specified,
- openid profile email is used by default.
-
isLoading property is set to true once the
- authentication state of the user is known to the SDK.
- user property is populated with details about the
- authenticated user. If user is null, no
- user is currently authenticated.
- error property is populated if any error occurs.
- const Component = () => {
const { authorize, user, isLoading, error } = useAuth0();
const login = async () => {
await authorize();
};
if (isLoading) {
return (
<View>
<Text>SDK is Loading</Text>
</View>
);
}
return (
<View>
{!user && <Button onPress={login} title="Log in" />}
{user && <Text>Logged in as {user.name}</Text>}
{error && <Text>{error.message}</Text>}
</View>
);
};
-
- auth0.webAuth
.authorize()
.then(credentials => console.log(credentials))
.catch(error => console.log(error));
-
- -- -- Web Authentication flows require a Browser application installed - on the device. When no Browser is available, an error of type -
-a0.browser_not_availablewill be raised via the - provided callback. -

- Check the FAQ for more information about the - alert box that pops up by default when using Web - Auth on iOS. -
--- -- See also - this blog post - for a detailed overview of Single Sign-On (SSO) on iOS. -
-
- Log the user out by using the clearSession method from
- the useAuth0 hook.
-
const Component = () => {
const { clearSession, user } = useAuth0();
const logout = async () => {
await clearSession();
};
return <View>{user && <Button onPress={logout} title="Log out" />}</View>;
};
-
- auth0.webAuth.clearSession().catch((error) => console.log(error));
-
- - The Credentials Manager allows you to securely store and retrieve - the user's credentials. The credentials will be stored encrypted - in Shared Preferences on Android, and in the Keychain on iOS. -
-
- The Auth0 class exposes the
- credentialsManager property for you to interact with
- using the API below.
-
-- -- 💡 If you're using Web Auth (
-authorize) through - Hooks, you do not need to manually store the credentials after - login and delete them after logout; the SDK does this - automatically. -
- When the users open your app, check for valid credentials. If they - exist, you can retrieve them and redirect the users to the app's - main flow without any additional login steps. -
-const isLoggedIn = await auth0.credentialsManager.hasValidCredentials();
if (isLoggedIn) {
// Retrieve credentials and redirect to the main flow
} else {
// Redirect to the login page
}
-
-
- - The credentials will be automatically renewed using the - refresh token, if the access token has expired. - This method is thread safe. -
-const credentials = await auth0.credentialsManager.getCredentials();
-
- -- -- 💡 You do not need to call credentialsManager.saveCredentials() - afterward. The Credentials Manager automatically persists the - renewed credentials. -
-
--- :warning: The
-requireLocalAuthenticationmethod is no - longer available as part of the -CredentialsManagerclass or the -useAuth0Hook from v4 of the SDK. -
--- ℹ️ You need to use at least version
-0.59.0of React - Native, as it usesFragmentActivityas the base - activity, which is required for biometric authentication to work. -
- You can enable an additional level of user authentication before - retrieving credentials using the local authentication supported by - the device, for example PIN or fingerprint on Android, and Face ID - or Touch ID on iOS. -
-- Refer to the instructions below to understand how to enable - authentication before retrieving credentials based on your setup: -
-Using Auth0 Class:
-
- The Auth0 class constructor now accepts a new
- parameter, which is an instance of the
- LocalAuthenticationOptions object. This needs to be
- passed while creating an instance of Auth0 to enable
- authentication before obtaining credentials, as shown in the code
- snippet below:
-
import Auth0 from 'react-native-auth0';
const localAuthOptions: LocalAuthenticationOptions = {
title: 'Authenticate to retreive your credentials',
subtitle: 'Please authenticate to continue',
description: 'We need to authenticate you to retrieve your credentials',
cancelTitle: 'Cancel',
evaluationPolicy: LocalAuthenticationStrategy.deviceOwnerWithBiometrics,
fallbackTitle: 'Use Passcode',
authenticationLevel: LocalAuthenticationLevel.strong,
deviceCredentialFallback: true,
};
const auth0 = new Auth0({
domain: config.domain,
clientId: config.clientId,
localAuthenticationOptions: localAuthOptions,
});
-
- Using Hooks (Auth0Provider):
-
- Auth0Provider now accepts a new parameter, which is an
- instance of the LocalAuthenticationOptions object. This
- needs to be passed to enable authentication before obtaining
- credentials, as shown in the code snippet below:
-
import { Auth0Provider } from 'react-native-auth0';
const localAuthOptions: LocalAuthenticationOptions = {
title: 'Authenticate to retreive your credentials',
subtitle: 'Please authenticate to continue',
description: 'We need to authenticate you to retrieve your credentials',
cancelTitle: 'Cancel',
evaluationPolicy: LocalAuthenticationStrategy.deviceOwnerWithBiometrics,
fallbackTitle: 'Use Passcode',
authenticationLevel: LocalAuthenticationLevel.strong,
deviceCredentialFallback: true,
};
const App = () => {
return (
<Auth0Provider
domain={config.domain}
clientId={config.clientId}
localAuthenticationOptions={localAuthOptions}
>
{/* YOUR APP */}
</Auth0Provider>
);
};
export default App;
-
-
- Detailed information on LocalAuthenticationOptions is
- available here
-
LocalAuthenticationOptions:
-- The options for configuring the display of local authentication - prompt, authentication level (Android only), and evaluation policy - (iOS only). -
-Properties:
-| Property | -Type | -Description | -Applicable Platforms | -
|---|---|---|---|
title |
- String |
- The title of the authentication prompt. | -Android, iOS | -
subtitle |
- String (optional) |
- The subtitle of the authentication prompt. | -Android | -
description |
- String (optional) |
- The description of the authentication prompt. | -Android | -
cancelTitle |
- String (optional) |
- The cancel button title of the authentication prompt. | -Android, iOS | -
evaluationPolicy |
- LocalAuthenticationStrategy (optional) |
-
- The evaluation policy to use when prompting the user for
- authentication. Defaults to
- deviceOwnerWithBiometrics.
- |
- iOS | -
fallbackTitle |
- String (optional) |
- The fallback button title of the authentication prompt. | -iOS | -
authenticationLevel |
- LocalAuthenticationLevel (optional) |
-
- The authentication level to use when prompting the user for
- authentication. Defaults to strong.
- |
- Android | -
deviceCredentialFallback |
- Boolean (optional) |
- - Should the user be given the option to authenticate with their - device PIN, pattern, or password instead of a biometric. - | -Android | -
-- -- :warning: You need a real device to test Local Authentication for - iOS. Local Authentication is not available in simulators. -
-
- The Credentials Manager will only throw
- CredentialsManagerError exceptions. You can find more
- information in the details property of the exception.
-
try {
const credentials = await auth0.credentialsManager.getCredentials();
} catch (error) {
console.log(error);
}
-
- Platform agnostic errors:
-- You can access the platform agnostic generic error codes as below : -
-try {
const credentials = await auth0.credentialsManager.getCredentials();
} catch (error) {
console.log(e.type);
}
-
-
- Note : We have platform agnostic error codes available only
- for CredentialsManagerError as of now.
-
| Generic Error Code | -Corresponding Error Code in Android | -Corresponding Error Code in iOS | -
|---|---|---|
INVALID_CREDENTIALS |
- INVALID_CREDENTIALS |
- - |
NO_CREDENTIALS |
- NO_CREDENTIALS |
- noCredentials |
-
NO_REFRESH_TOKEN |
- NO_REFRESH_TOKEN |
- noRefreshToken |
-
RENEW_FAILED |
- RENEW_FAILED |
- renewFailed |
-
STORE_FAILED |
- STORE_FAILED |
- storeFailed |
-
REVOKE_FAILED |
- REVOKE_FAILED |
- revokeFailed |
-
LARGE_MIN_TTL |
- LARGE_MIN_TTL |
- largeMinTTL |
-
INCOMPATIBLE_DEVICE |
- INCOMPATIBLE_DEVICE |
- - |
CRYPTO_EXCEPTION |
- CRYPTO_EXCEPTION |
- - |
BIOMETRICS_FAILED |
-
- OneOf BIOMETRIC_NO_ACTIVITY,BIOMETRIC_ERROR_STATUS_UNKNOWN,BIOMETRIC_ERROR_UNSUPPORTED,BIOMETRIC_ERROR_HW_UNAVAILABLE,BIOMETRIC_ERROR_NONE_ENROLLED,BIOMETRIC_ERROR_NO_HARDWARE,BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED,BIOMETRIC_AUTHENTICATION_CHECK_FAILED,BIOMETRIC_ERROR_DEVICE_CREDENTIAL_NOT_AVAILABLE
- |
- biometricsFailed |
-
NO_NETWORK |
- NO_NETWORK |
- - |
API_ERROR |
- API_ERROR |
- - |
- We appreciate feedback and contribution to this repo! Before you get - started, please see the following: -
-- To provide feedback or report a bug, - please raise an issue on our issue tracker. -
- -- Please do not report security vulnerabilities on the public Github - issue tracker. The - Responsible Disclosure Program - details the procedure for disclosing security issues. -
-
-
-
- Auth0 is an easy to implement, adaptable authentication and - authorization platform. To learn more checkout - Why Auth0? -
-- This project is licensed under the MIT license. See the - - LICENSE - file for more info. -
- - -Options for building a URL for /authorize
Custom parameters to send to /authorize
- Where the authorization server will redirect back after success - or failure. -
-The response_type value
-Random string to prevent CSRF attacks.
-- Options for configuring the SDK's clear session behaviour. -
-Optional
- custom- Android only: Custom scheme to build the - callback URL with. -
-Optional
- use- This will use older callback URL. See - https://github.com/auth0/react-native-auth0/blob/master/MIGRATION_GUIDE.md#callback-url-migration - for more details. -
-Parameters for sending to the Auth0 logout endpoint.
-Optional
- federated
-
- If true, the user will be signed out of any
- connected identity providers in addition to their Auth0 session.
-
false
- https://auth0.com/docs/authenticate/login/logout/log-users-out-of-idps -
-Optional
- return- Specify a custom redirect URL to be used. Normally, you - wouldn't need to call this method manually as the default - value is autogenerated for you. -
-- If you are using this, ensure a proper redirect URL is - constructed in the following format Android: - {YOUR_APP_PACKAGE_NAME}.auth0://{AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback - iOS: - {PRODUCT_BUNDLE_IDENTIFIER}.auth0://{AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback -
-
- If you have useLegacyCallbackUrl set to true then
- the redirect URL should in the format Android:
- {YOUR_APP_PACKAGE_NAME}://{AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
- iOS:
- {PRODUCT_BUNDLE_IDENTIFIER}://{AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
-
Options for creating a new user.
-- The name of the database connection where to create the user -
-The user's email
-Optional
- family_The user's family name(s)
-Optional
- given_The user's given name(s)
-Optional
- metadata
-
- Additional information that will be stored in
- user_metadata
-
Optional
- name
- The user's full name
-Optional
- nickname
- The user's nickname
-The user's password
-Optional
- picture
- A URL pointing to the user's picture
-Optional
- username
- The user's username
-- Options for obtaining user tokens from an external provider's - token -
-Optional
- audience
- The API audience to request
-Optional
- scope
-
- The scopes requested for the issued tokens. e.g.
- openid profile
-
- The token returned by the native social authentication solution -
-- The identifier that indicates the native social authentication - solution -
-Optional
- user- Additional profile attributes to set or override, only on select - native social authentication solutions -
-
- Options for the /oauth/token endpoint to exchange a
- code for an access token
-
Custom parameters to send to the /oauth/token endpoint
-The code returned by /authorize.
- The original redirectUri used when calling
- /authorize.
-
- The value used to generate the code challenge sent to
- /authorize.
-
- The options for configuring the display of local authentication - prompt, authentication level (Android only) and evaluation policy - (iOS only). -
-Optional
- authentication- The authentication level to use when prompting the user for - authentication. Defaults to LocalAuthenticationLevel.strong. - Applicable for Android only. -
-Optional
- cancel- The cancel button title of the authentication prompt. - Applicable for both Android and iOS. -
-Optional
- description
- - The description of the authentication prompt. - Applicable for Android only. -
-Optional
- device- Should the user be given the option to authenticate with their - device PIN, pattern, or password instead of a biometric. - Applicable for Android only. -
-Optional
- evaluation- The evaluation policy to use when prompting the user for - authentication. Defaults to - LocalAuthenticationStrategy.deviceOwnerWithBiometrics. - Applicable for iOS only. -
-Optional
- fallback- The fallback button title of the authentication prompt. - Applicable for iOS only. -
-Optional
- subtitle
- - The subtitle of the authentication prompt. - Applicable for Android only. -
-- The title of the authentication prompt. - Applicable for both Android and iOS. -
-- The options for completing the passwordless login with email - request -
-Optional
- audience
- The API audience to request
-The code numeric value (OTP)
-The email where the link/code was received
-Optional
- scope
- The scopes to request
-Options for logging in using an OOB code
-Optional
- binding- The code used to bind the side channel (used to deliver the - challenge) with the main channel you are using to authenticate. - This is usually an OTP-like code delivered as part of the - challenge message. -
-The token received in the previous login response
-The out of band code received in the challenge response.
-Options for logging in using an OTP code
-Optional
- audience
- The API audience
-The token received in the previous login response
-- The one time password code provided by the resource owner, - typically obtained from an MFA application such as Google - Authenticator or Guardian. -
-Options for logging in using a recovery code
-The token received in the previous login response
-The recovery code provided by the end-user.
-- The options for completing the passwordless login with SMS request -
-Optional
- audience
- Optional API audience to request
-The code numeric value (OTP)
-The phone number where the code was received
-Optional
- scope
- Optional scopes to request
-Options for the logout endpoint
-Custom parameters to send to the logout endpoint
-Optional
- clientThe client identifier of the one requesting the logout
-Optional
- federated
- - Whether the logout should include removing session for federated - IdP. -
-Optional
- return- URL where the user is redirected to after logout. It must be - declared in you Auth0 Dashboard -
-Options for multifactor challenge.
-Optional
- authenticatorThe ID of the authenticator to challenge.
-Optional
- challenge- A whitespace-separated list of the challenges types accepted by - your application. Accepted challenge types are oob or otp. - Excluding this parameter means that your client application - accepts all supported challenge types. -
-The token received in the previous login response
-- Options for authenticating using the username & password - grant. -
-Optional
- audience
- - The identifier of Resource Server (RS) to be included as - audience (aud claim) of the issued access token -
-The user's password
-The name of the Realm where to Auth (or connection name)
-Optional
- scope
-
- The scopes requested for the issued tokens. e.g.
- openid profile
-
The user's username or email
-Options for requesting passwordless login using email
-Optional
- authOptional parameters, used when strategy is 'linḱ'
-The email to send the link/code to
-Optional
- send
- - The passwordless strategy, either 'link' or - 'code' -
-Options for requesting passwordless login using SMS
-Optional
- authOptional passwordless parameters
-The phone number to send the link/code to
-Optional
- send
- - The passwordless strategy, either 'link' or - 'code' -
-Refresh token parameters
-The issued refresh token
-Optional
- scope
-
- The scopes requested for the issued tokens. e.g.
- openid profile
-
Options for resetting a user's password.
-The name of the database connection of the user
-The user's email
-Options for the revoke refresh token endpoint.
-The user's issued refresh token
-- Authorize the user using Auth0 Universal Login. See - WebAuth#authorize -
-Optional
- parameters:
- WebAuthorizeParameters
-
- The parameters that are sent to the
- /authorize endpoint.
-
Optional
- options:
- WebAuthorizeOptions
- - Options for customizing the SDK's handling - of the authorize call -
-- Authorize the user using an email code. See - Auth#loginWithEmail -
-- Authorize user with credentials using the Password Realm Grant. - See - Auth#passwordRealm -
-- Authorize the user using an Out Of Band authentication code. See - Auth#loginWithOOB -
-- Autohrize the user using a One Time Password code. See - Auth#loginWithOTP. -
-- Authorize user with credentials using the Password Realm Grant. - See - Auth#passwordRealm -
-- Authorize the user using a multi-factor authentication Recovery - Code. See - Auth#loginWithRecoveryCode -
-- Authorize the user using a SMS code. See - Auth#loginWithSMS -
-- Cancel any ongoing Universal Login transaction. This works only - on iOS and not on any other platforms -
-- Clears the user's credentials without clearing their web - session and logs them out. -
-- Clears the user's web session, credentials and logs them - out. See - WebAuth#clearSession -
-Optional
- parameters:
- ClearSessionParameters
- - Additional parameters to send to the Auth0 - logout endpoint. -
-Optional
- options:
- ClearSessionOptions
- - Options for configuring the SDK's clear - session behaviour. -
-An object representing the last exception
-- Gets the user's credentials from the native credential - store. If credentials have expired, they are automatically - refreshed by default. See - CredentialsManager#getCredentials -
-Optional
- scope:
- string
- The scopes used to get the credentials
-Optional
- minTtl:
- number
- - The minimum time in seconds that the access - token should last before expiration -
-Optional
- parameters: Record<string, unknown>
- - Any additional parameters to send in the request - to refresh expired credentials. -
-Optional
- forceRefresh:
- boolean
-
- If true, credentials are always
- refreshed regardless of their expiry, provided a
- valid refresh token is available.
-
- Whether the SDK currently holds valid, unexpired credentials. -
-Optional
- minTtl:
- number
- - The minimum time in seconds that the access - token should last before expiration -
-
- true if there are valid credentials. Otherwise,
- false.
-
- A flag that is true until the state knows that a user is either - logged in or not -
-- Request an email with instructions to change password of a user - Auth#resetPassword -
-- Revokes an issued refresh token. See - Auth#revoke -
-- Start the passwordless email login flow. See - Auth#passwordlessWithEmail -
-- Send a challenge for multi-factor authentication. See - Auth#multifactorChallenge -
-- Start the passwordless SMS login flow. See - Auth#passwordlessWithSMS -
-- The user profile as decoded from the ID token after - authentication -
-An object representing the last exception
-- A flag that is true until the state knows that a user is either - logged in or not -
-- The user profile as decoded from the ID token after - authentication -
-Options for accessing the /userinfo endpoint.
The user's access token
-
- Options for controlling the SDK's behaviour when calling the
- /authorize endpoint.
-
Optional
- custom- Android only: Custom scheme to build the - callback URL with. -
-Optional
- ephemeral- iOS only: Disable Single-Sign-On (SSO). It only - affects iOS with versions 13 and above. -
-false
Optional
- leeway
- - The amount of leeway, in seconds, to accommodate potential clock - skew when validating an ID token's claims. -
-60 seconds.
-Optional
- use- This will use older callback URL. See - https://github.com/auth0/react-native-auth0/blob/master/MIGRATION_GUIDE.md#callback-url-migration - for more details. -
-Optional
- useSFSafari
- iOS only: Uses
- SFSafariViewController instead of
- ASWebAuthenticationSession. If empty object is set,
- the presentationStyle defaults to
- SafariViewControllerPresentationStyle.fullScreen
-
- This can be used as a boolean value or as an object which sets
- the presentationStyle. See the examples below for
- reference
-
Optional
- presentationawait authorize({}, {useSFSafariViewController: true});
-
- or
-await authorize({}, {useSFSafariViewController: {presentationStyle: SafariViewControllerPresentationStyle.fullScreen}});
-
-
- Parameters that are sent to a call to the
- /authorize endpoint.
-
Optional
- additional- Any additional arbitrary parameters to send along in the URL. -
-Optional
- audience
- - The intended API identifier that will be the consumer for the - issued access token. -
-Optional
- connection
- The database connection in which to look for users.
-Optional
- invitation- The invitation URL for those users who have been invited to join - a specific organization. -
-Optional
- max- The maximum age in seconds that the resulting ID token should be - issued for. -
-Optional
- nonce
- - One-time random value that is used to prevent replay attacks. -
-Optional
- organization
- - The organization in which user's should be authenticated - into. -
-Optional
- redirect- Specify a custom redirect URL to be used. Normally, you - wouldn't need to call this method manually as the default - value is autogenerated for you. -
-- If you are using this, ensure a proper redirect URL is - constructed in the following format Android: - {YOUR_APP_PACKAGE_NAME}.auth0://{AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback - iOS: - {PRODUCT_BUNDLE_IDENTIFIER}.auth0://{AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback -
-
- If you have useLegacyCallbackUrl set to true then
- the redirect URL should in the format Android:
- {YOUR_APP_PACKAGE_NAME}://{AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
- iOS:
- {PRODUCT_BUNDLE_IDENTIFIER}://{AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
-
Optional
- scope
-
- The scopes requested for the issued tokens. e.g.
- openid profile
-
Optional
- state
- Random string to prevent CSRF attacks.
-The token used to make API calls
-- Used to denote when the token will expire, as a UNIX timestamp -
-A token in JWT format that has user claims
-Optional
- refreshThe token used to refresh the access token
-Optional
- scope?: string
- Represents the scope of the current token
-The type of the token, e.g.: Bearer
-Optional
- headers?: Headers
- Optional
- json?: TData
- Optional
- ok?: boolean
- Optional
- text?: string
- Optional
- env?: any
- Optional
- name?: string
- Optional
- version?: string
- Optional
- address?: string
- Optional
- birthdate?: string
- Optional
- email?: string
- Optional
- emailOptional
- familyOptional
- gender?: string
- Optional
- givenOptional
- locale?: string
- Optional
- middleOptional
- name?: string
- Optional
- nickname?: string
- Optional
- phoneOptional
- phoneOptional
- picture?: string
- Optional
- preferredOptional
- profile?: string
- Optional
- sub?: string
- Optional
- updatedOptional
- website?: string
- Optional
- zoneinfo?: string
-
- Class for interfacing with the Auth0 Authentication API endpoints. -
-See
-- https://auth0.com/docs/api/authentication -
-