Can I stop parseFromUrl() reloading the page?

I’m using OktaAuth from okta-auth-js to implement SSO in my application. After calling signInWithRedirect() the browser gets redirected as expected, and I then call token.parseFromUrl().

My problem is that this last function appears to reload the current page. I assume this is because, as stated in the docs:

After reading values, this method will rewrite either the hash fragment or search query portion of the URL ... so that the code or tokens are no longer present or visible to the user.

This is a bit of an inconvenience for me - I’m wondering if there’s a way to suppress this rewriting of the URL?

Hello,

If your application is a Single Page App you might want to consider using okta_post_message as the response_mode. This will do the /authorize flow in a hidden iFrame and your main app page will not need to refresh.

https://github.com/okta/samples-js-angular/blob/master/custom-login/src/app/login/login.component.ts#L58

To not refresh using the redirect model you could define a custom restoreOriginalUri in the authParams.
For example,

        authParams: {
          issuer: "https://{DOMAIN}.okta.com/oauth2/default",
		  scopes: ['openid', 'email', 'profile'],
          restoreOriginalUri: async (oktaAuth, originalUri) => {
            // Save an extra redirect (page refresh)
            console.log('***NO REDIRECT***');
            oktaSignIn.authClient.token.getUserInfo()
            .then(displayUserInfo)     <-- user defined function to update page content
            .catch((err) => {
              console.log(err);
            });
          }
        }