Angular app non stop refresh after login with code and state query string

Yes, you need to configure the SDK as follows:

  • set the authorizationParams.redirect_uri to a unprotected route, e.g. window.location.origin + '/callback'
  • ensure the router has a route configured for callback that does not require authentication
  • call loginWithRedirect and configure appState.target to be /, this ensures our SDK redirects back to the home page after the user was authenticated succesful.

The important part is, as mentioned, to redirect back to an unprotected route that does not call loginWithRedirect.

On top of that, you should not call loginWithRedirect when the user is already authenticated.

Even better would be to use our AuthGuard to protect the home URL, but you still need the /callback redirect_uri part.

1 Like