Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NextAuth GitHub integration throws an error - refresh_token_expires_in missing in Prisma schema #182

Closed
EkaanshArora opened this issue Jul 12, 2022 · 3 comments · Fixed by #187

Comments

@EkaanshArora
Copy link
Contributor

Describe the bug
When you scaffold a project with NextAuth and Prisma. Setting up the env file and using the GitHub provider throws an error as the Prisma Account schema is missing the refresh_token_expires_in field. The NextAuth docs page suggests adding it to the schema.

Exact error message:

Unknown arg `refresh_token_expires_in` in data.refresh_token_expires_in for type AccountUncheckedCreateInput. 

To Reproduce
Steps to reproduce the behavior:

  1. Scaffold a new project
  2. Select NextAuth & Prisma
  3. Setup GitHub credentials in the env file
  4. Use this snippet:
import { signIn } from "next-auth/react"

export default function Component() {
  return <>
    <button onClick={() => signIn()}>Sign in</button>
  </>
}
  1. Sign in with GitHub
  2. See the error in the log

Expected behavior
The sign-in should succeed.

The default GitHub integration throwing an error can be confusing for someone new to NextAuth. I'm happy to create a PR and add the field to the schema if it makes sense. If we don't want to change the default Schema for NextAuth, it might make sense to explore another default provider instead of GitHub.

@juliusmarminge
Copy link
Member

If we don't want to change the default Schema for NextAuth, it might make sense to explore another default provider instead of GitHub.

Kind of agree with this. Maybe use Discord? Or just a simple Credentials-provider like the trpc/examples-kitchen-sink

@nexxeln
Copy link
Member

nexxeln commented Jul 12, 2022

I think Discord is a good idea.

@ozgurrgul
Copy link

For anyone seeing this error like me when trying github provider: you basically need to extend Account schema in schema.prisma:

model Account {
    id                String  @id @default(cuid())
    userId            String
    .....
    refresh_token_expires_in Int <<< Added new to provide github support
}

I tested with only Github provider and it works, not sure with multiple providers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants