Auth0 Home Blog Docs

Dynamic callback after login



When i am on a internal webapp page but the user session or it’s token are invalid, the webapp redirect the user to the login page. When the user login in the webapp, it return to home page directly.
How do I keep the user on the current page if in the client configuration I have already defined the URL of callback p.e. localhost:8080/myapp/callback?


Although the redirect after authentication needs to happen to one of the white-listed callback URL’s and as such you cannot use the current page as the redirect you can still perform an additional redirect after having processed the authentication response. There are multiple ways you can accomplish this, for example, you can use the fact that the OAuth 2.0 state parameter is round-tripped back to your client application as way to know the page the end-user was visiting before the login (see The State Parameter). In addition, you can just store the current page in application specific storage like a session or web storage and then redirect based on that.