Skip to main content

@authgear/react-native / ReactNativeContainer

Class: ReactNativeContainer

ReactNativeContainer is the entrypoint of the SDK. An instance of a container allows the user to authenticate, reauthenticate, etc.

Every container has a name. The default name of a container is default. If your app supports multi login sessions, you can use multiple containers with different names. You are responsible for managing the list of names in this case.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new ReactNativeContainer(options?): ReactNativeContainer

Parameters

NameType
options?ContainerOptions

Returns

ReactNativeContainer

Defined in

packages/authgear-react-native/index.d.ts:916

Properties

delegate

Optional delegate: ReactNativeContainerDelegate

Delegation for customizing the behavior of your application. You can implement your own delegation and the container will evaluate them if needed.

Defined in

packages/authgear-react-native/index.d.ts:871

Accessors

accessToken

get accessToken(): undefined | string

The access token of this container.

Returns

undefined | string

Defined in

packages/authgear-react-native/index.d.ts:914

set accessToken(accessToken): void

Parameters

NameType
accessTokenundefined | string

Returns

void

Defined in

packages/authgear-react-native/index.d.ts:915


clientID

get clientID(): undefined | string

OIDC client ID

Returns

undefined | string

Defined in

packages/authgear-react-native/index.d.ts:886

set clientID(clientID): void

Parameters

NameType
clientIDundefined | string

Returns

void

Defined in

packages/authgear-react-native/index.d.ts:887


isSSOEnabled

get isSSOEnabled(): boolean

Is SSO enabled

Returns

boolean

Defined in

packages/authgear-react-native/index.d.ts:893

set isSSOEnabled(isSSOEnabled): void

Parameters

NameType
isSSOEnabledboolean

Returns

void

Defined in

packages/authgear-react-native/index.d.ts:894


name

get name(): string

The name of the container. The name is used as the namespace of TokenStorage. One use case is to use multiple containers with different names to support signing in multiple accounts.

Returns

string

Default Value

"default"

@public

Defined in

packages/authgear-react-native/index.d.ts:879

set name(name): void

Parameters

NameType
namestring

Returns

void

Defined in

packages/authgear-react-native/index.d.ts:880


preAuthenticatedURLEnabled

get preAuthenticatedURLEnabled(): boolean

Is Pre Authenticated URL enabled

Returns

boolean

Defined in

packages/authgear-react-native/index.d.ts:900

set preAuthenticatedURLEnabled(preAuthenticatedURLEnabled): void

Parameters

NameType
preAuthenticatedURLEnabledboolean

Returns

void

Defined in

packages/authgear-react-native/index.d.ts:901


sessionState

get sessionState(): SessionState

The current SessionState of this container.

Returns

SessionState

Defined in

packages/authgear-react-native/index.d.ts:907

set sessionState(sessionState): void

Parameters

NameType
sessionStateSessionState

Returns

void

Defined in

packages/authgear-react-native/index.d.ts:908

Methods

addEmail

addEmail(options): Promise<void>

addEmail() opens the settings page in a UIImplementation for the user to add an email. After adding the email, the UIImplementation will be closed.

You can refer to SettingsActionOptions for more customization.

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:986


addPhone

addPhone(options): Promise<void>

addPhone() opens the settings page in a UIImplementation for the user to add a phone number. After adding the phone number, the UIImplementation will be closed.

You can refer to SettingsActionOptions for more customization.

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:995


addUsername

addUsername(options): Promise<void>

addUsername() opens the settings page in a UIImplementation for the user to add a username. After adding the username, the UIImplementation will be closed.

You can refer to SettingsActionOptions for more customization.

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1004


authenticate

authenticate(options): Promise<AuthenticateResult>

authenticate() starts the authentication process in a UIImplementation. After authentication, the UIImplementation will be closed and the user is logged in. After this method resolves, biometric authentication is disabled. Call enableBiometric() again to enable biometric authentication for the new signed in user.

You can refer to AuthenticateOptions for more customization.

Parameters

NameType
optionsAuthenticateOptions

Returns

Promise<AuthenticateResult>

Defined in

packages/authgear-react-native/index.d.ts:968


authenticateAnonymously

authenticateAnonymously(): Promise<AuthenticateResult>

authenticateAnonymously() creates an anonymous user without showing any UI. You may first enable Anonymous Users in Authgear Portal (Your project > Authentication > Anonymous Users > Enable anonymous users).

Returns

Promise<AuthenticateResult>

Defined in

packages/authgear-react-native/index.d.ts:1080


authenticateBiometric

authenticateBiometric(options): Promise<AuthenticateResult>

Authenticate with biometric authentication. Platform specific biometric authentication UI will be shown. You may first enable biometric authentication in Authgear Portal (Your Project > Authentication > Biometric > Enable biometric authentication).

You can refer to BiometricOptions for more customization.

Parameters

NameType
optionsBiometricOptions

Returns

Promise<AuthenticateResult>

Defined in

packages/authgear-react-native/index.d.ts:1162


canReauthenticate

canReauthenticate(): boolean

canReauthenticate() reports whether the current user can reauthenticate. The information comes from the ID token and the ID token is NOT verified.

Returns

boolean

Defined in

packages/authgear-react-native/index.d.ts:929


changeEmail

changeEmail(originalEmail, options): Promise<void>

changeEmail() opens the settings page in a UIImplementation for the user to change their email. After changing the email, the UIImplementation will be closed.

You can refer to SettingsActionOptions for more customization.

Parameters

NameType
originalEmailstring
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1013


changePassword

changePassword(options): Promise<void>

changePassword() opens the settings page in a UIImplementation for the user to change their password. After changing the password, the UIImplementation will be closed.

You can refer to SettingsActionOptions for more customization.

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:977


changePhone

changePhone(originalPhone, options): Promise<void>

changePhone() opens the settings page in a UIImplementation for the user to change their phone number. After changing the phone number, the UIImplementation will be closed.

You can refer to SettingsActionOptions for more customization.

Parameters

NameType
originalPhonestring
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1022


changeUsername

changeUsername(originalUsername, options): Promise<void>

changeUsername() opens the settings page in a UIImplementation for the user to change their username. After changing the username, the UIImplementation will be closed.

You can refer to SettingsActionOptions for more customization.

Parameters

NameType
originalUsernamestring
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1031


checkBiometricSupported

checkBiometricSupported(options): Promise<void>

Check whether biometric is supported on the current device. If biometric is not supported, then a platform specific error is thrown.

Parameters

NameType
optionsBiometricOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1129


configure

configure(options): Promise<void>

configure() configures the container with the client ID and the endpoint. It also does local IO to retrieve the refresh token. It only obtains the refresh token locally and no network call will be triggered. So the session state maybe outdated for some reason, e.g. user session is revoked. fetchUserInfo should be called to obtain the latest user session state.

configure() can be called more than once if it failed. Otherwise, it is NOT recommended to call it more than once.

Parameters

NameType
optionsConfigureOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:957


deleteAccount

deleteAccount(options): Promise<void>

deleteAccount() opens the settings page in a UIImplementation for the user to delete their account. After deletion, the UIImplementation will be closed and the user is logged out.

You can refer to SettingsActionOptions for more customization.

Parameters

NameType
optionsSettingsActionOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1040


disableBiometric

disableBiometric(): Promise<void>

Disable biometric authentication for the signed in user. After disabling, the user may not be able to authenticate with biometric until it is enabled again.

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1142


enableBiometric

enableBiometric(options): Promise<void>

Enable biometric authentication for the signed in user. Platform specific biometric authentication UI will be shown. You may first enable biometric authentication in Authgear Portal (Your Project > Authentication > Biometric > Enable biometric authentication).

You can refer to BiometricOptions for more customization.

Parameters

NameType
optionsBiometricOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1152


fetch

fetch(input, init?): Promise<Response>

Fetch function for you to call your application server. The fetch function will include Authorization header in your application request, and handle refresh access token automatically.

Parameters

NameType
inputany
init?RequestInit

Returns

Promise<Response>

Defined in

packages/authgear-react-native/index.d.ts:1112


fetchUserInfo

fetchUserInfo(): Promise<UserInfo>

fetchUserInfo() fetches the up-to-date user info.

Returns

Promise<UserInfo>

Defined in

packages/authgear-react-native/index.d.ts:1097


getAuthTime

getAuthTime(): undefined | Date

getAuthTime() reports the last time the user was authenticated. The information comes from the ID token and the ID token is NOT verified.

Returns

undefined | Date

Defined in

packages/authgear-react-native/index.d.ts:936


getIDTokenHint

getIDTokenHint(): undefined | string

getIDTokenHint() returns the ID token for the OIDC id_token_hint parameter.

Returns

undefined | string

Defined in

packages/authgear-react-native/index.d.ts:922


isBiometricEnabled

isBiometricEnabled(): Promise<boolean>

Check whether biometric was enabled for the signed in user.

Returns

Promise<boolean>

Defined in

packages/authgear-react-native/index.d.ts:1135


logout

logout(options?): Promise<void>

logout() signs out the user without showing any UI. The refresh token will be cleared. The biometric authentication is kept, so the user can authenticateBiometric again.

Parameters

NameTypeDescription
options?ObjectLogout options
options.force?boolean-

Returns

Promise<void>

Remarks

If force parameter is set to true, all potential errors (e.g. network error) would be ignored.

Defined in

packages/authgear-react-native/index.d.ts:1071


makePreAuthenticatedURL

makePreAuthenticatedURL(options): Promise<string>

Share the current authenticated session to a web browser.

ConfigureOptions.preAuthenticatedURLEnabled must be set to true to use this method.

You can refer to PreAuthenticatedURLOptions for more customization.

Parameters

NameType
optionsPreAuthenticatedURLOptions

Returns

Promise<string>

Defined in

packages/authgear-react-native/index.d.ts:1172


open

open(page, options?): Promise<void>

Open Authgear pages. Currently only settings pages are available.

You can refer to SettingOptions for more customization.

Parameters

NameType
pagePage
options?SettingOptions

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1058


promoteAnonymousUser

promoteAnonymousUser(options): Promise<AuthenticateResult>

promoteAnonymousUser() opens the anonymous user promotion page in the UIImplementation and the user has to authenticate. The flow is similar to authenticate(), the UIImplementation will be closed and the user is logged in after authentication. After this method resolves, biometric authentication is disabled. Call enableBiometric() again to enable biometric authentication for the new signed in user.

You can refer to PromoteOptions for more customization.

Parameters

NameType
optionsPromoteOptions

Returns

Promise<AuthenticateResult>

Defined in

packages/authgear-react-native/index.d.ts:1091


reauthenticate

reauthenticate(options, biometricOptions?): Promise<ReauthenticateResult>

reauthenticate() starts the reauthentication process via biometric or in the UIImplementation.

If biometricOptions is given, biometric is used when possible.

You can refer to ReauthenticateOptions and BiometricOptions for more customization.

Parameters

NameType
optionsReauthenticateOptions
biometricOptions?BiometricOptions

Returns

Promise<ReauthenticateResult>

Defined in

packages/authgear-react-native/index.d.ts:1050


refreshAccessTokenIfNeeded

refreshAccessTokenIfNeeded(): Promise<void>

refreshAccessTokenIfNeeded() refreshes the access token if needed. After the task has completed, the updated access token will be stored in this.accessToken.

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1104


refreshIDToken

refreshIDToken(): Promise<void>

refreshIDToken() asks the server to issue an ID token with latest claims. After refreshing, getIDTokenHint() and canReauthenticate() may return up-to-date value.

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:943


wechatAuthCallback

wechatAuthCallback(code, state): Promise<void>

WeChat auth callback function. In WeChat login flow, after returning from the WeChat SDK, this function should be called to complete the authorization.

Parameters

NameTypeDescription
codestringWeChat Authorization code.
statestringWeChat Authorization state.

Returns

Promise<void>

Defined in

packages/authgear-react-native/index.d.ts:1122

  • Table of contents
  • Constructors
    • constructor
  • Properties
    • delegate
  • Accessors
    • accessToken
    • clientID
    • isSSOEnabled
    • name
    • preAuthenticatedURLEnabled
    • sessionState
  • Methods
    • addEmail
    • addPhone
    • addUsername
    • authenticate
    • authenticateAnonymously
    • authenticateBiometric
    • canReauthenticate
    • changeEmail
    • changePassword
    • changePhone
    • changeUsername
    • checkBiometricSupported
    • configure
    • deleteAccount
    • disableBiometric
    • enableBiometric
    • fetch
    • fetchUserInfo
    • getAuthTime
    • getIDTokenHint
    • isBiometricEnabled
    • logout
    • makePreAuthenticatedURL
    • open
    • promoteAnonymousUser
    • reauthenticate
    • refreshAccessTokenIfNeeded
    • refreshIDToken
    • wechatAuthCallback