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.

Setting "code" query parameter breaks auth0 state

See original GitHub issue

If you’re logged in to my site, and then add “?code=blah” to the href, auth0 now thinks I’m not logged in. I realize this has something to do with the oauth redirect flow, but the problem is that I need to use that query parameter (stripe uses it for their oauth flow: https://stripe.com/docs/connect/collect-then-transfer-guide).

Proposed change: if code param fails to change the auth0 state, auth0-react should fall back on whatever it would have the state be if that code were excluded (instead of just saying there’s no user).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
adamjmcgrathcommented, Sep 3, 2020

Hey @martinrojas - I am waiting on an upstream dependency before I do another release - should be 1 week - 2 max

2reactions
adamjmcgrathcommented, Aug 25, 2020

Hi @dutsik @asktree

I have a branch (https://github.com/auth0/auth0-react/compare/skip-redirect-callback) where I’ve added the config option skipRedirectCallback, if true this will ignore the code/state parameters. You can apply this setting to be true on callback routes for other OAuth providers where you know the SDK doesn’t need to handle the callback params. Or conversely, you can set it to true, unless you know the route to be the auth0 callback path, eg

<Auth0Provider
  domain={domain}
  clientId={clientId}
  redirectUri={`${window.location.origin}/auth0-callback`}
  skipRedirectCallback={window.location.pathname !== '/auth0-callback'}>

Can you try it out and let me know if it meets your needs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I not have code and state parameters in the URL ...
A problem I encountered was that after a successful login, a code and state parameter are present in the URL of the SPA...
Read more >
Troubleshoot WordPress Plugin Invalid State Errors - Auth0
The most common cause of the invalid state error is when the callback URL is cached on the server. Exclude caching on your...
Read more >
Angular 10 SPA Error on redirect after login - Auth0 Community
Angular 10 SPA Error on redirect after login: there are no query params available for parsing - Auth0 Community.
Read more >
Rules Execution Best Practices - Auth0
Learn about best practices for executing Auth0 rules.
Read more >
Code Exchange removes query parameters from redirect URL
(I'm guessing) The Auth0 package assembles the redirect_uri and targetUrl from the cookie and redirects the user there, thereby removing the ...
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