SIGNIN_OAUTH_ERROR on keycloak expected 200 OK, got: 404 Not Found , providers id with weird suffix (google2 instead of google) #8654
Replies: 3 comments
-
i have made other attempts, i reproduced an example using the provided nextauth template next-auth-example, this is the complete error:
any feedback is appreciated also tried to host the site on netfly, maybe it was a vercel related issue, still i got the very same error here: https://melodic-pika-d6ce7e.netlify.app/ some more logging popped up when i downgraded to next-auth 4.2.1, everything seems right:
|
Beta Was this translation helpful? Give feedback.
-
Sounds/looks like an issue with a trailing slash on the issuer or similar, not a https://www.datamanagementitalia.it/iamdemo/auth/realms/NUT/.well-known/openid-configuration returns 404 so the thrown error is expected. |
Beta Was this translation helpful? Give feedback.
-
Hi, aside from turbo being a reason for this error, the issuer url responding with 404 can be a reason as well (or maybe turbo is the reason why the issuer URL answers with 404. I don't use it so I don't know how it behaves). I had this problem twice: First, when trying to implement next-auth locally working with just npm run dev in my IDE and second, when trying to deploy my app with docker. The first time I had this issue, I noticed that I had to delete the /auth from my issuer URL for getting it to work. Working with keycloak as identity provider btw. Tbh, I haven't really figured out yet, why my issuer URL changes depending on how I run my app but I hope this might help some people here. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Environment
System:
OS: Windows 10 10.0.22621
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
Memory: 9.47 GB / 31.71 GB
Binaries:
Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22621.2283.0), Chromium (117.0.2045.31)
Internet Explorer: 11.0.22621.1
Reproduction URL
https://github.com/fabioportieri/nextauth-notworking.git
Describe the issue
i have weird behaviour when trying to make a oauth2 connection to a keycloack authorization server when deployed to vercel, it works fine on development, this is the error from the log upon hitting:
https://chatgpt-turbo-rouge.vercel.app/api/auth/signin/keycloak
[next-auth][error][SIGNIN_OAUTH_ERROR]
https://next-auth.js.org/errors#signin_oauth_error expected 200 OK, got: 404 Not Found {
error: {
message: 'expected 200 OK, got: 404 Not Found',
stack: 'OPError: expected 200 OK, got: 404 Not Found\n' +
' at processResponse (/var/task/.next/server/chunks/610.js:13972:15)\n' +
' at Issuer.discover (/var/task/.next/server/chunks/610.js:14464:26)\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
' at async openidClient (/var/task/.next/server/chunks/610.js:8162:18)\n' +
seems like the issuer is not found somewhat
another weird thing happening, is that provider id does not match, i tried adding a google provider:
when i tried to login with google i get a redirect uri mismatch error, when decoding the error returned in the url i see this:
If you're the app developer, register the redirect URI in the Google Cloud Console.
�mhttps://developers.google.com/identity/protocols/oauth2/web-server#authorization-errors-redirect-uri-mismatch �*O
redirect_uri�?https://chatgpt-turbo-rouge.vercel.app/api/auth/callback/**google2**
please note it's "google2" when instead should be "google"
also, in the keycloack logs, i saw this:
2023-09-15 15:00:48,539 WARN [org.keycloak.events] (default task-1586) type=LOGIN_ERROR, realmId=NUT, clientId=chatgpt-turbo2, userId=null, ipAddress=195.120.87.13, error=client_not_found
please note it mentions "chatgpt-turbo2" instead of my defined clientId "chatgpt-turbo"
so as it is now something really weird is happening on production and i can' tell what's going on
i'll try to put up an example repo, note that the code used is very minimal, it's just a nextjs app router that perform a sign in in the page.tsx like so
How to reproduce
for the complete code:
https://github.com/fabioportieri/nextauth-notworking.git
the online project:
https://nextauth-notworking.vercel.app/
write a nextjs app with app router
with this configuration
src\app\api\auth[...nextauth]\route.ts
src\app\layout.tsx\layout.tsx:
NextAuthProvider.tsx:
page.tsx:
Expected behavior
to be able to authenticate in production as it does in development mode
Beta Was this translation helpful? Give feedback.
All reactions