Next.js Discord

Discord Forum

next-auth google signin issue (OAuthAccountNotLinked) caus of MongoDBAdapterOptions.collections

Unanswered
Giant Chinchilla posted this in #help-forum
Open in Discord
Giant ChinchillaOP
I am currently facing an issue with NextAuth's Google sign-in when using the MongoDBAdapter.

- The problem arises when I customize the collection name in the MongoDBAdapterOptions.
- Specifically, when I set the collections.Users to "deltas," the sign-in process does not work as expected, resulting in an OAuthAccountNotLinked error and improper redirection with the session to the homepage.

temp fix: Issue Resolution:

Removing the custom collection name (Users: "deltas") resolves the problem, but it creates an additional "User" collection which I want to avoid.

Questions:

- Has anyone encountered similar issues with NextAuth Google sign-in and MongoDBAdapter custom collection names?
- How can I configure the MongoDBAdapter to use my "Deltas" collection without causing sign-in issues?
- Is there a specific configuration or workaround to ensure proper redirection with the session to the homepage after Google sign-in?

url => localhost:3000/auth/login

button => sigin(google)

choosing an account

url changes => localhost:3000/auth/login?callbackUrl=http%3A%2F%2Flocalhost%3A3000&error=OAuthAccountNotLinked



question code on stackoverflow
https://stackoverflow.com/q/77658844/15107749

0 Replies