question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failing to redirect to route after logging in

See original GitHub issue

Issue and Steps to Reproduce

Failing to redirect to specified page after being logged in, the page gets stuck with the callback url being filled -

image

I’ve tried to add the customCallback but that doesnt seem to resolve the issue, heres my current code -

App.js -

const CallbackSuccessComponent = () => {
  const navigate = useNavigate();
  const { idToken } = useOidcIdToken();

  useEffect(() => {
    console.log(idToken);
    if (idToken) {
      navigate("/automagiqapps/ui/dashboard", { replace: true });
      window.location.reload();
    }
  }, [idToken]);

  return <div>CallbackSuccessComponent</div>;
};

function App() {
  const configuration = {
    client_id: "<CLIENT_ID>",
    redirect_uri: "${window.location.origin}/automagiqapps/ui/#callback",
    scope: "openid profile",
    authority:
      "<AZURE_AUTH_URL>",
    // service_worker_relative_url: "./OidcServiceWorker.js",
    // service_worker_only: true,
  };

  return (
    <OidcProvider
      configuration={configuration}
      callbackSuccessComponent={CallbackSuccessComponent}
    >
      <Router>
        <SnackbarProvider
          maxSnack={2}
          autoHideDuration={2000}
          anchorOrigin={{
            vertical: "bottom",
            horizontal: "center",
          }}
        >
          <Routes>{routes}</Routes>
        </SnackbarProvider>
      </Router>
    </OidcProvider>
  );
}

Login logic, pretty much copied from examples -

{!isAuthenticated && (
  <ListItemButton
    sx={{ px: 3, pt: 2.5, pb: 2.5 }}
    onClick={() => login("/automagiqapps/ui/dashboard")}
  >
    <ListItemIcon>
      <LoginIcon />
    </ListItemIcon>
    <ListItemText
      primary="Login"
      primaryTypographyProps={{
        fontSize: 15,
        fontWeight: "medium",
        variant: "body2",
      }}
    />
  </ListItemButton>
)}

Versions

"@axa-fr/react-oidc": "^6.10.13"

Screenshots

Expected

Redirected to specified route

Actual

Stuck on callback URL after pressing login and being authenticated

Additional Details

  • Installed packages:

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
solrankoscommented, Nov 22, 2022

Any update on this @sharjeel-jan? i seem to have a simular issue

0reactions
guillaume-chervetcommented, Nov 25, 2022

hi @sharjeel-jan, did you solve your problem?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Login/Redirect fails in production - Auth0 Community
I'm using Auth0 in an Angular app, and I just deployed a test build to production, where it fails outright upon login.
Read more >
Fail to redirect to the previous page after authenticating the ...
I added in a middleware called isLoggedIn and I saved req.session.returnTo = req.originalUrl; and I passed in this middleware to 2 routes (get(' ......
Read more >
Login Fails to Redirect when Using Custom URL - Laracasts
Hi,. I'm using Laravel 5.2 and I wish to change the login URL from the default /login to /adminLogin. Right now I have...
Read more >
Unable to Redirect anywhere after login - Questions
my site stuck at this point ,not opening my secure routes (making single page React website)
Read more >
After login user gets initially redirected to /code #3292 - GitHub
I got hash routing enabled and sometimes when the redirect is too slow my application tries to find the route /code which obviously...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found