auth0 / auth0-react

Auth0 SDK for React Single Page Applications (SPA)
MIT License
873 stars 254 forks source link

`authorizationParams=[object Object]` after upgrading to v2.0.0 #479

Closed jonasb closed 1 year ago

jonasb commented 1 year ago

Describe the problem

After upgrading to v2.0.0 the browser is opening an auth0 url where the authorizationParams is [object Object], i.e. invalid. The url is https://dossierhq-tutorial.eu.auth0.com/authorize?authorizationParams=%5Bobject%20Object%5D&client_id=....

image

What was the expected behavior?

It should be possible to login.

Reproduction

(Sorry, haven't had the time to recreate a minimal repro)

Can the behavior be reproduced using the React SDK Playground?

If so, provide steps:

Where applicable, please include:

  • The smallest possible sample app that reproduces the undesirable behavior
  • Log files (redact/remove sensitive information)
  • Application settings (redact/remove sensitive information)
  • clientId and domain (these are publicly available)
  • Screenshots

Environment

Please provide the following:

seljabali commented 1 year ago

I'm seeing the exact same problem:

https://....auth0.com/authorize
?authorizationParams=[object Object]
&client_id=L...
&scope=openid profile email
&response_type=code
&response_mode=query
&state=bXYy...==
&nonce=TktlbV...==
&code_challenge=A985...
&code_challenge_method=S256
&auth0Client=eyJuYW...=
frederikprijck commented 1 year ago

Thanks for reaching out. Can you verify this happens when both auth0-react v2 and auth0-spa-js v2 are installed locally?

I tried reproducing this, but it looks like we can successfully authenticate after upgrading our React sample to v2, you can have a look at https://github.com/auth0-samples/auth0-react-samples.

Can you reproduce the broken behavior in that sample? Or point to any differences that could cause it in your situation?

seljabali commented 1 year ago

Hi @frederikprijck.

npm install @auth0/auth0-spa-js fixed the issue!

Perhaps we needed this dependency all along? It worked fine beforehand however without it.

In any case, if it's a hard new requirement, let's please have the v2 migration guide reflect that.

Best!

frederikprijck commented 1 year ago

Hey @seljabali ,

In any case, if it's a hard new requirement,

No, you should not have to explicitly install auth0-spa-js manually, sorry about that confusion. But installing auth0-react should install auth0-spa-js, and installing v2 of auth0-react should install v2 of auth0-spa-js.

Looking at the error here, I assume it's mixing auth0-react v2 with auth0-spa-js v1, which is not supported.

I am mostly wondering what versions you had, without explicitly installing auth0-spa-js.

How did you upgrade auth0-react? Did npm warn you about any incompatible versions?

seljabali commented 1 year ago

@frederikprijck,

I just checked out the commit before adding auth0-spa-js dependency manually and ran it, however didn't come across the error. Perhaps it was a build caching issue? I'm not sure.

Thanks again for the help! Hope this helps others.

jonasb commented 1 year ago

@frederikprijck I'm using pnpm as the package manager (wrapped by rush). Adding @auth0/auth0-spa-js didn't fix the issue for me, but purging all node_modules and reinstalling worked for me (rush purge && rush update).

Thanks for the assistance! 👋

frankalbenesius commented 1 year ago

my team also ran into this problem while using pnpm. removing node_modules and re-installing also worked for us. thank you for the help!