nhost / hasura-auth

Authentication for Hasura.
https://nhost.io
MIT License
377 stars 114 forks source link

Grant: missing session or misconfigured provider 404 error when signing in with google #355

Closed Glenas7 closed 1 year ago

Glenas7 commented 1 year ago

I have run into an issue using google OAuth that seems to be related with Nhost's configuration.

The callback works fine but once signed in by google, when trying to return to the app (next.js app hosted on vercel), a 404 error is returned with the message "Grant: missing session or misconfigured provider". It seems this error has something to do with cookies being lost and the cross-origin request being blocked due to some misconfiguration on the server.

Google client and secret work locally with the Nhost CLI and are properly included in the Settings > Sign-In Methods of the Nhost dashboard. The vercel link is also included as a client URL in the Settings > Authentication section. I'm not sure what else to check on Nhost's side, if anyone runs into this issue and finds a solution it would be great to hear about it!

Glenas7 commented 1 year ago

Hi again! I solved this issue, it was because I had not set the allowed javascript URI's in google's console. To solve the error, you have to add your URIs to this part of the google oauth settings as well (screenshot).

image

I had originally done that, but since it is not explicitly mentioned in the nhost google oauth guide (https://docs.nhost.io/authentication/sign-in-with-google) I removed it because I was running into another error and was trying to fix that by following the docs exactly. In the end that other error was fixed by spinning up a fresh nhost project and copying everything over.

I have created a PR to add this to the docs (https://github.com/nhost/nhost/pull/1751) in case that is helpful!