Confirms a user’s account by verifying the username and confirmation code. Optionally, tags can be provided.
The username of the user to confirm.
The code sent to the user for verification.
Optionaltags: string[]Optional tags associated with the user.
A promise that resolves with an ESPAPIResponse object if the user is successfully signed up.
Initiates the forgot password flow for a user by sending their username to the API.
The username of the user who wants to reset their password.
A promise that resolves with an ESPAPIResponse indicating success.
Retrieves the currently logged-in user.
This method checks if the access token is available and valid. If the access token is expired, it attempts to refresh the session using the refresh token. If successful, it returns an instance of the ESPRMUser class containing the user's tokens. If no valid access token is found, it returns null.
A promise that resolves to an instance of ESPRMUser if the user is logged in, or null if not.
Logs in a user by their username and password, returning an ESPRMUser instance upon success.
The username of the user logging in.
The password of the user.
A promise that resolves to an instance of ESPRMUser containing the user's tokens.
Logs in a user using OAuth by first requesting an OAuth code and then exchanging it for tokens. This method combines the functionality of requesting OAuth code and logging in with the code.
The identity provider for which to request an OAuth login code.
A promise that resolves to an instance of ESPRMUser containing user tokens.
Exchanges a previously obtained OAuth authorization code for user tokens.
Unlike ESPRMAuth.loginWithOauth, this method does not request the
code itself. The caller supplies an authorization code that was already
acquired out-of-band — for example, from the WeChat native SDK in the CN
region — and this method performs only the token-exchange step, returning
an authenticated ESPRMUser.
The OAuth authorization code to exchange for tokens.
Optionaloptions: LoginWithOauthCodeOptionsOptional flags controlling the exchange. Set
wechatTokenOnly to add the wechat_token_only=true flag required by
the WeChat token exchange; it also sends the WeChat
identity_provider by default, which identityProvider overrides.
A promise that resolves to an instance of ESPRMUser containing
the access, ID, and refresh tokens.
Logs in a user using an OTP (One-Time Password) and a session token.
The username of the user attempting to log in.
The OTP received by the user.
The session token associated with the OTP request.
A promise that resolves to an instance of ESPRMUser containing user tokens.
Requests a login OTP (One-Time Password) for the specified username.
The username for which the OTP is requested.
A promise that resolves to a sessionToken string indicating the OTP session.
Registers a new user by providing their username and password.
The username for the new account.
The password for the new account.
A promise that resolves to an ESPAPIResponse indicating the success in sending sign up code.
Sets a new password for a user by providing their username, a new password, and a verification code.
The username of the user who is setting a new password.
The new password to be set for the user.
The verification code used to authorize the password change.
A promise that resolves to an ESPAPIResponse indicating the success of the operation.
The
ESPRMAuthclass provides comprehensive authentication functionality for users. It includes methods for account sign-up, login, password management, OTP-based authentication, and OAuth-based login flows. Key features include:This class simplifies the integration of authentication mechanisms in applications built on the ESP RainMaker ecosystem.