react-fullstack-graphql icon indicating copy to clipboard operation
react-fullstack-graphql copied to clipboard

Auth0-Apollo example has invalid idToken even with HS256

Open miyi opened this issue 9 years ago • 10 comments

auth0 apollo example fails at login. Previous issues indicate that HS256 is the problem, i've changed that already. Here is the error message:

CreateUser.js:80 Error: GraphQL error: The provided idToken is invalid. Please see https://auth0.com/docs/tokens/id_token for how to obtain a valid idToken

I noticed in LoginAuth0.js file that authResult returns a accessToken but idToken, idTokenPayload, and refreshToken, are all undefined.

Does anyone else have this issue? what am I doing wrong? I did not make any other changes

miyi avatar Sep 13 '17 02:09 miyi

I get the same error.

morajabi avatar Sep 17 '17 14:09 morajabi

There are a few options:

  • Either, disable OIDC conformance in your Auth0 client settings in the dashboard and make sure you don't set the audience. As this is both less secure and might break further down the road (Auth0s support for HS256 has decreased over time), it's the least preferred option.
  • Or, use the custom authentication feature to support RS256 tokens using the new feature Resolver Functions. We've prepared an example for custom email-password authentication already, more examples will follow. If you want to try it out, please reach out in Framework Preview feedback thread that's mentioned in the README.
  • Lastly, you can follow an approach similar to this one: https://github.com/graphcool/templates/pull/77 This sets up an Auth0 rule and does not require any custom setup on Graphcool's side.

marktani avatar Sep 19 '17 09:09 marktani

Either, disable OIDC conformance in your Auth0 client settings in the dashboard and make sure you don't set the audience. As this is both less secure and might break further down the road (Auth0s support for HS256 has decreased over time), it's the least preferred option.

Thanks, @marktani 👍 This was my problem but fortunately, I've discovered it earlier! Anyway, Thanks for the response. Mind adding it in a Troubleshooting in the readme?

morajabi avatar Sep 19 '17 17:09 morajabi

great, this solves my problem too.

miyi avatar Sep 29 '17 03:09 miyi

According to react-native-auth0 docs I was setting audience but disabling it solves my problem too. Thanks @marktani

OGPoyraz avatar Oct 26 '17 17:10 OGPoyraz

Does anyone know if this issue is any different for Facebook login with Auth0? I've followed the instructions to disable OIDC conformance and change the algorithm to HS256 but auth0 login with facebook still seems to be returning an RS256 token and so the error Error: GraphQL error: The provided idToken is invalid persists.

Findiglay avatar Nov 11 '17 00:11 Findiglay

@Findiglay Are you sure you are using the correct URL referring to that project in Auth0?

morajabi avatar Nov 11 '17 07:11 morajabi

@morajabi Can you clarify which url you refer to? I only have one auth0 client and settings seem to be correct. Authentication is working but it's always returning RS256.

Findiglay avatar Nov 11 '17 12:11 Findiglay

@Findiglay Do you have a minimal repo or something we can check? It's almost impossible to solve the problem this way.

morajabi avatar Nov 11 '17 12:11 morajabi

@Findiglay Are you setting the audience? Be sure you remove the audience settings.

e8miliano avatar Nov 13 '17 14:11 e8miliano