Next.js Discord

Discord Forum

Access Denied in Google Authentication

Answered
Leonberger posted this in #help-forum
Open in Discord
LeonbergerOP
I'm following nextjs14 tutorial and I've followed along, but I'm facing access denied issue. I'm using next-auth and earlier the issue was mismatch URI bit after changing it, this error occurred.
Answered by Leonberger
Oh found it, it was a typo in route.js. I was using ._id instead of .id
View full answer

20 Replies

Toyger
most likely your login url is accessible only for authorized users
check your middleware and auth.config maybe you set login url wrong
...
pages: {
    signIn: '/login',
...
LeonbergerOP
I'm using singIn from next-auth/react
Toyger
check your clientId and clientSecret, they should be enclosed in quotes in env file
LeonbergerOP
I fixed that previously, still the same issue
ahh
wrap the value in quotes
is that equal to the end accidental?
@averydelusionalperson wrap the value in quotes
LeonbergerOP
oh, are they meant to be in quotes?
then wrap them in quotes, having two = might cause some issues
LeonbergerOP
i don't think that's the issue because MONGODB_URI also contains multiple = but that is working, only the next-auth is not working(which i tried with quotes)
LeonbergerOP
is this ok?
it is
@Leonberger is this ok?
Toyger
check clien id and secret maybe there some typo
also when you create them did you add Authorized redirect URIs as in documentation https://next-auth.js.org/providers/google
LeonbergerOP
Oh found it, it was a typo in route.js. I was using ._id instead of .id
Answer
LeonbergerOP
Thank you people for your help. ^ ^
lmao
noice