nicoalbanese / kirimase

Build full-stack Next.js apps, incredibly fast
https://kirimase.dev
MIT License
2.39k stars 107 forks source link

GitHub login broken for Next Auth #95

Closed elie222 closed 6 months ago

elie222 commented 7 months ago

Basic project set up with GitHub as only auth provider for Next auth:

[next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR] 
https://next-auth.js.org/errors#oauth_callback_handler_error 
Invalid `prisma.account.create()` invocation:

{
  data: {
    provider: "github",
    type: "oauth",
    providerAccountId: "123",
    access_token: "xyz",
    expires_at: 123,
    refresh_token: "xyz",
    refresh_token_expires_in: 15724800,
    ~~~~~~~~~~~~~~~~~~~~~~~~
    token_type: "bearer",
    scope: "",
    userId: "abc",
?   id?: String,
?   id_token?: String | Null,
?   session_state?: String | Null
  }
}
elie222 commented 7 months ago

Fix: https://next-auth.js.org/providers/github

GitHub returns a field on Account called refresh_token_expires_in which is a number. See their docs. Remember to add this field to your database schema, in case if you are using an Adapter.