Auth0 Home Blog Docs

Getting both tokens and redirection with Lock 10 for web

lock-10
tokens
redirect

#1

After testing Lock 10 for Web I am wandering how redirect to the welcome page by using the options and still saving token on LocalStorage.
For now with the basic example I can either redirect or save the token.
How can I get both?


#2

You should provide more information by updating your question. In particular this seems an issue associated with code so sharing snippets of the relevant code may be helpful. If you’re following a quickstart or other sample then do provide an exact link to it.


#3

From lock/v10 I have tested successfully the example below the section 2. Authenticating and Getting User Info.
This means I was able see the value of accessToken and profile.

In the next step I tried to redirect once connected to another page using the example under More Examples and in lock’s config options.
By modifying the first eg. to use option when initializing Auth0Lock, the method lock.on("authenticated", function(authResult) {... is not called anymore


#4

From lock/v10 I have tested successfully the example below the section 2. Authenticating and Getting User Info.
This means I was able see the value of accessToken and profile.

In the next step I tried to redirect once connected to another page using the example under More Examples and in lock’s config options.
By modifying the first eg. to use option when initializing Auth0Lock, the method lock.on("authenticated", function(authResult) {... is not called anymore


#5

The example in the Lock reference docs highlight specific functionality so if you want something more relevant for a complete application you should follow the quickstart more relevant to your technology stack; I’m linking to the jQuery one as it’s the most general, but there may be one more relevant to your case.

If you follow the quickstart you’ll also notice that although there’s a sample for using Lock embedded directly in the client application the recommended approach is actually to leverage the hosted login page instead. The recommendation would be for you to follow a quickstart if what you’re looking for is a more complete sample of the integration.

As an additional note, in the more example section the snippet of Lock is using the code response type so the actual authentication response should be processed by the back-end of a regular web application and in this case the authenticated event of Lock does not apply as that is meant for flows used by SPA’s and not the code flow used for regular web applications.


#6