Access is denied with Google Authentication using NextAuth.js #7212
-
Question 💬OverviewHi, I'm looking for a solution to a problem I'm having! I am developing a web application using Next.js and Rails. Versions
Repositoryhttps://github.com/shirotamaki/outdoor-heart-sutra What I want to achieveI would like to implement Google Authentication Login in production mode as well, which has been realized in development mode. How to reproduceDevelopment Mode
Production mode
What I triedI predicted. I confirmed that the problem occurred in the Regarding GoogleCloudPlatform, the "approved redirect URI" is already registered. This time, since we are in production mode and not in a production environment, I am aware that the "approved redirect URI" will use the same URI as in development mode.
How to reproduce ☕️Error log
The code that is causing the problem
Rails server log
Contributing 🙌🏽No, I am afraid I cannot help regarding this |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 4 replies
-
Is the callback route being protected and not allowed to be accessed without authentication? |
Beta Was this translation helpful? Give feedback.
-
@Crazypersonalph Yes. It is set up so that it cannot be accessed without authentication. |
Beta Was this translation helpful? Give feedback.
-
That is the problem |
Beta Was this translation helpful? Give feedback.
-
@Crazypersonalph Thank you for your response. |
Beta Was this translation helpful? Give feedback.
-
Considering that it is working in development, I do not believe that to be the issue |
Beta Was this translation helpful? Give feedback.
-
@shirotamaki I found your issue It is just that the Rails server is returning a 302 Found message instead of a 200 OK message, that is causing the access denied message. |
Beta Was this translation helpful? Give feedback.
-
@Crazypersonalph
I changed it to return only status code
Login succeeded !! Thank you for your help. |
Beta Was this translation helpful? Give feedback.
-
did you find the issue? if yes please Explain it |
Beta Was this translation helpful? Give feedback.
-
Their rails server was configured to return the wrong status code, causing the access denied message. |
Beta Was this translation helpful? Give feedback.
@Crazypersonalph
Thanks for checking issue.
I can check that the Rails server is returning a 302.
I changed it to return only status code
200 OK
, without redirect.