autoParseHash
is falsenew Auth0Lock(clientID, domain, options)
Initializes a new instance of Auth0Lock
configured with your application’s clientID
and your account’s domain
from your Auth0 management dashboard. The third and optional parameter is an options
object used to configure Lock for your application’s needs. You can find this information at your application settings.
getUserInfo(accessToken, callback)
Once the user has logged in and you are in possession of a token, you can use that token to obtain the user’s profile with getUserInfo
. This method replaces the deprecated getProfile()
.
show(options)
The show
method displays the widget. Beginning with Lock version 10.2.0, the show
method can now accept an options
object as a parameter. Note that this parameter is meant to be used as a way to override your Lock’s options
for this particular displaying of the widget - options should be set when instantiating Lock, and overridden, only if needed for your specific use case, here.
The following subset of options
to be overridden from the values they were given (or their defaults) when Lock was instantiated:
show
method, please see the user configurable options page.
Options override examples:
var lock = new Auth0Lock(clientId, domain, options);
. Options should only be passed to show
in order to override your previously set options while displaying the widget at this particular time and place.
There is an additional option that can be set in the show
method called flashMessage
.
show
method, not for use in the normal options
object when instantiating Lock. The flashMessage
object shows an error or success flash message when Lock is shown. It has the following parameters:
error
or success
.flashMessage
option is to handle authorization errors. The flashMessage
can be populated with error description text.
tester@example.com
were now to try to sign in, being a user who is blocked, the user will be shown Lock again, with a top bar displaying the error message, rather than simply failing to login and Lock closing.
hide()
The hide
method closes the widget if it is currently open. The widget closes itself under most circumstances, so this method would primarily be invoked in specific use cases only. For instance, one might wish to listen for the unrecoverable_error
event and then hide
the Lock and redirect to their own custom error page. Another example is users who are implementing popup mode, and might need to manually hide
the widget after the authenticated
event fires.
Example usage to hide (close) the Lock widget in popup mode:
on
method can be used to listen for particular events and react to them.
show
: emitted when Lock is shown. Has no arguments.hide
: emitted when Lock is hidden. Has no arguments.unrecoverable_error
: emitted when there is an unrecoverable error, for instance when no connection is available. Has the error as the only argument.authenticated
: emitted after a successful authentication. Has the authentication result as the only argument. The authentication result contains the token which can be used to get the user’s profile or stored to log them in on subsequent checks.authorization_error
: emitted when authorization fails. Has error as the only argument.hash_parsed
: every time a new Auth0Lock object is initialized in redirect mode (the default), it will attempt to parse the hash part of the url looking for the result of a login attempt. This is a low level event for advanced use cases and authenticated
and authorization_error
should be preferred when possible. After that this event will be emitted with null
if it couldn’t find anything in the hash. It will be emitted with the same argument as the authenticated
event after a successful login or with the same argument as authorization_error
if something went wrong. This event won’t be emitted in popup mode because there is no need to parse the url’s hash part.forgot_password ready
: emitted when the “Forgot password” screen is shown. (Only in Version >10.18
)forgot_password submit
: emitted when the user clicks on the submit button of the “Forgot password” screen. (Only in Version >10.14
)signin ready
: emitted when the “Sign in” screen is shown.signup ready
: emitted when the “Sign up” screen is shown.signin submit
: emitted when the user clicks on the submit button of the “Login” screen. (Only in Version >10.18
)signup submit
: emitted when the user clicks on the submit button of the “Sign Up” screen. (Only in Version >10.18
)federated login
: emitted when the user clicks on a social connection button. Has the connection name and the strategy as arguments. (Only in Version >10.18
)socialOrPhoneNumber ready
: emitted when the screen with Social + Phone Number is shownsocialOrPhoneNumber submit
: emitted when the Passwordless screen with Social + Phone Number is submittedsocialOrEmail ready
: emitted when the Passwordless screen with Social + Email is shownsocialOrEmail submit
: emitted when the Passwordless screen with Social + Email is submittedvcode ready
: emitted when the Passwordless screen with the one-time-password is shownvcode submit
: emitted when the Passwordless screen with the one-time-password is submittedauthenticated
event listener has a single argument, an authResult
object. This object contains the following properties: accessToken
, idToken
, state
, refreshToken
and idTokenPayload
.
An example use of the authenticated
event:
false
. You’ll need to call resumeAuth
to complete the authentication flow. This method is useful when you’re using a client-side router that uses a #
to handle urls (angular2 with useHash
, or react-router with hashHistory
).
null
.checkSession
method allows you to acquire a new token from Auth0 for a user who is already authenticated against Auth0 for your domain. It takes the following parameters:
/authorize
. If you omit them, it will use the ones provided when initializing Auth0.