new WebAuth(options)
Handles all the browser's AuthN/AuthZ flows
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Members
popup :Popup
Type:
- Source:
redirect :Redirect
Type:
- Source:
Methods
authorize(optionsopt)
Redirects to the hosted login page (/authorize
) in order to start a new authN/authZ transaction.
After that, you'll have to use the parseHash
function at the specified redirectUri
.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
Example
auth0.authorize({
audience: 'https://mystore.com/api/v2',
scope: 'read:order write:order',
responseType: 'token',
redirectUri: 'https://example.com/auth/callback'
});
changePassword(options, cb)
Request an email with instruction to change a user's password
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
|||||||||
cb |
changePasswordCallback |
checkSession(optionsopt, cb)
Renews an existing session on Auth0's servers using response_mode=web_message
Allows you to acquire a new token from Auth0 for a user who already
has an SSO session established against Auth0 for your domain.
If the user is not authenticated, the authentication result will be empty
and you'll receive an error like this: {error: 'login_required'}
.
The method accepts any valid OAuth2 parameters that would normally be sent to /authorize
.
Everything happens inside an iframe, so it will not reload your application or redirect away from it.
Important: If you're not using the hosted login page to do social logins,
you have to use your own social connection keys.
If you use Auth0's dev keys, you'll always get login_required
as an error when calling checkSession
.
Important: Because there is no redirect in this method, responseType: 'code'
is not supported and will throw an error.
Remember to add the URL where the authorization request originates from to the Allowed Web Origins list of your Auth0 Application in the Dashboard under your Applications's Settings.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
||||||||||||||||||||||||||||||||||||
cb |
checkSessionCallback |
- Source:
- See:
Example
auth0.checkSession({
audience: 'https://mystore.com/api/v2',
scope: 'read:order write:order'
},
function(err, authResult) {
// Authentication tokens or error
});
crossOriginAuthenticationCallback()
Runs the callback code for the cross origin authentication call. This method is meant to be called by the cross origin authentication callback url.
- Deprecated:
- Use
crossOriginVerification
instead.
- Use
- Source:
crossOriginVerification()
Runs the callback code for the cross origin authentication call. This method is meant to be called by the cross origin authentication callback url.
- Source:
login(options, cb)
Logs the user in with username and password using the correct flow based on where it's called from:
- If you're calling this method from the Universal Login Page, it will use the usernamepassword/login endpoint
- If you're calling this method outside the Universal Login Page, it will use the cross origin authentication (/co/authenticate) flow
You can use either
username
oremail
to identify the user, butusername
will take precedence overemail
. After the redirect toredirectUri
, useparseHash
to retrieve the authentication data. Notice that when using the cross origin authentication flow, some browsers might not be able to successfully authenticate if 3rd party cookies are disabled. See here for more information..
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options used in the Properties
|
||||||||||||||||||||||||||||
cb |
crossOriginLoginCallback | Callback function called only when an authentication error, like invalid username or password, occurs. For other types of errors, there will be a redirect to the |
- Source:
- See:
-
Requires
Implicit
grant. For more information, read https://auth0.com/docs/clients/client-grant-types.
logout(optionsopt)
Redirects to the auth0 logout endpoint
If you want to navigate the user to a specific URL after the logout, set that URL at the returnTo parameter. The URL should be included in any the appropriate Allowed Logout URLs list:
- If the client_id parameter is included, the returnTo URL must be listed in the Allowed Logout URLs set at the Auth0 Application level (see Setting Allowed Logout URLs at the App Level).
- If the client_id parameter is NOT included, the returnTo URL must be listed in the Allowed Logout URLs set at the account level (see Setting Allowed Logout URLs at the Account Level).
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
parseHash(options, cb)
Parse the url hash and extract the Auth response from a Auth flow started with authorize
Only validates id_tokens signed by Auth0 using the RS256 algorithm using the public key exposed
by the /.well-known/jwks.json
endpoint of your account.
Tokens signed with the HS256 algorithm cannot be properly validated.
Instead, a call to userInfo
will be made with the parsed access_token
.
If the userInfo
call fails, the userInfo
error will be passed to the callback.
Tokens signed with other algorithms will not be accepted.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
||||||||||||||||||||
cb |
authorizeCallback |
- Source:
Example
auth0.parseHash({ hash: window.location.hash }, function(err, authResult) {
if (err) {
return console.log(err);
}
// The contents of authResult depend on which authentication parameters were used.
// It can include the following:
// authResult.accessToken - access token for the API specified by `audience`
// authResult.expiresIn - string with the access token's expiration time in seconds
// authResult.idToken - ID token JWT containing user profile information
auth0.client.userInfo(authResult.accessToken, function(err, user) {
// Now you have the user's information
});
});
passwordlessLogin(options, cb)
Logs in the user by verifying the verification code (OTP) using the cross origin authentication (/co/authenticate) flow. You can use either phoneNumber
or email
to identify the user.
This only works when 3rd party cookies are enabled in the browser. After the /co/authenticate call, you'll have to use the parseHash
function at the redirectUri
specified in the constructor.
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options used in the Properties
|
||||||||||||||||||
cb |
crossOriginLoginCallback | Callback function called only when an authentication error, like invalid username or password, occurs. For other types of errors, there will be a redirect to the |
- Source:
passwordlessStart(options, cb)
Starts a passwordless authentication transaction.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
||||||||||||||||||||||||||||||||
cb |
function |
passwordlessVerify(options, cb)
Verifies the passwordless TOTP and redirects to finish the passwordless transaction
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
||||||||||||||||||||||||
cb |
function |
- Source:
renderCaptcha(element, options, callbackopt)
Renders the login captcha challenge in the provided element. This function can only be used in the context of a Classic Universal Login Page.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
element |
HTMLElement | The element where the captcha needs to be rendered |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object | The configuration options for the captcha Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
captchaLoadedCallback |
<optional> |
An optional callback called after captcha is loaded |
- Source:
renderPasswordlessCaptcha(element, options, callbackopt)
Renders the passwordless captcha challenge in the provided element. This function can only be used in the context of a Classic Universal Login Page.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
element |
HTMLElement | The element where the captcha needs to be rendered |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object | The configuration options for the captcha Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
captchaLoadedCallback |
<optional> |
An optional callback called after captcha is loaded |
- Source:
renderPasswordResetCaptcha(element, options, callbackopt)
Renders the password reset captcha challenge in the provided element. This function can only be used in the context of a Classic Universal Login Page.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
element |
HTMLElement | The element where the captcha needs to be rendered |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object | The configuration options for the captcha Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
captchaLoadedCallback |
<optional> |
An optional callback called after captcha is loaded |
- Source:
renderSignupCaptcha(element, options, callbackopt)
Renders the signup captcha challenge in the provided element. This function can only be used in the context of a Classic Universal Login Page.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
element |
HTMLElement | The element where the captcha needs to be rendered |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object | The configuration options for the captcha Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
captchaLoadedCallback |
<optional> |
An optional callback called after captcha is loaded |
- Source:
renewAuth(optionsopt, cb)
Executes a silent authentication transaction under the hood in order to fetch a new tokens for the current session.
This method requires that all Auth is performed with authorize
Watch out! If you're not using the hosted login page to do social logins, you have to use your own social connection keys. If you use Auth0's dev keys, you'll always get login_required
as an error when calling this method.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
cb |
authorizeCallback |
signup(options, cb)
Creates a new user in a Auth0 Database connection
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
||||||||||||||||||||||||||||||||||||
cb |
signUpCallback |
signupAndAuthorize(options, cb)
Signs up a new user, automatically logs the user in after the signup and returns the user token. The login will be done using /oauth/token with password-realm grant type.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
||||||||||||
cb |
tokenCallback |
- Source:
- See:
validateAuthenticationResponse(options, parsedHash, cb)
Validates an Auth response from a Auth flow started with authorize
Only validates id_tokens signed by Auth0 using the RS256 algorithm using the public key exposed
by the /.well-known/jwks.json
endpoint of your account.
Tokens signed with the HS256 algorithm cannot be properly validated.
Instead, a call to userInfo
will be made with the parsed access_token
.
If the userInfo
call fails, the userInfo
error will be passed to the callback.
Tokens signed with other algorithms will not be accepted.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
||||||||||||||||
parsedHash |
Object | an object that represents the parsed hash |
||||||||||||||||
cb |
authorizeCallback |
- Source: