Next.js Discord

Discord Forum

🔰SocialAuth problem (next-auth, prisma-adapter)

Unanswered
Siamese posted this in #help-forum
Open in Discord
SiameseOP
Hi to all 👋 .
I have a problem with authorization through social networks: github, google. When clicking on the authorization button, it redirects to the link "http://localhost:3000/api/auth/signin?error=Callback" with the message "Try signing in with a different account". I was looking for a solution to this problem, but I couldn't find it, so I'm writing here. Most likely, this is due to the incompatibility of the new versions of prisma-adapter and next-auth.
This is an article from stackoverflow with a similar problem, maybe it will help to understand the essence of the error:
https://stackoverflow.com/questions/69219455/how-to-use-next-auth-with-github-and-prisma

25 Replies

SiameseOP
Here's what the terminal says with this error:
[next-auth][debug][adapter_getUserByAccount] { args: [ { providerAccountId: '110691752', provider: 'github' } ] }
[next-auth][error][adapter_error_getUserByAccount] 
https://next-auth.js.org/errors#adapter_error_getuserbyaccount
Invalid `prisma.account.findUnique()` invocation:

{
  where: {
    provider_providerAccountId: {
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
      providerAccountId: "110691813",
      provider: "github"
    },
?   id?: String,
?   provider_providerACcountId?: AccountProviderProviderACcountIdCompoundUniqueInput,
?   AND?: AccountWhereInput | AccountWhereInput[],
?   OR?: AccountWhereInput[],
?   NOT?: AccountWhereInput | AccountWhereInput[],
?   userId?: StringFilter | String,
?   type?: StringFilter | String,
?   provider?: StringFilter | String,
?   providerACcountId?: StringFilter | String,
?   refresh_token?: StringNullableFilter | String | Null,
?   access_token?: StringNullableFilter | String | Null,
?   expires_at?: IntNullableFilter | Int | Null,
?   token_type?: StringNullableFilter | String | Null,
?   scope?: StringNullableFilter | String | Null,
?   id_token?: StringFilter | String,
?   session_state?: StringNullableFilter | String | Null,
?   user?: UserRelationFilter | UserWhereInput
  },
  select: {
    user: true
  }
}
Unknown argument `provider_providerAccountId`. Did you mean `provider_providerACcountId`? Available options are marked with ?. {
  message: '\n' +
    'Invalid `prisma.account.findUnique()` invocation:\n' +
    '\n' +
    '{\n' +
    '  where: {\n' +
    '    provider_providerAccountId: {\n' +
    '    ~~~~~~~~~~~~~~~~~~~~~~~~~~\n' +
    '      providerAccountId: "110691813",\n' +
    '      provider: "github"\n' +
    '    },\n' +
    '?   id?: String,\n' +
    '?   provider_providerACcountId?: AccountProviderProviderACcountIdCompoundUniqueInput,\n' +
    '?   AND?: AccountWhereInput | AccountWhereInput[],\n' +
    '?   OR?: AccountWhereInput[],\n' +
    '?   NOT?: AccountWhereInput | AccountWhereInput[],\n' +
    '?   userId?: StringFilter | String,\n' +
    '?   type?: StringFilter | String,\n' +
    '?   provider?: StringFilter | String,\n' +
    '?   providerACcountId?: StringFilter | String,\n' +
    '?   refresh_token?: StringNullableFilter | String | Null,\n' +
    '?   access_token?: StringNullableFilter | String | Null,\n' +
    '?   expires_at?: IntNullableFilter | Int | Null,\n' +
    '?   token_type?: StringNullableFilter | String | Null,\n' +
    '?   scope?: StringNullableFilter | String | Null,\n' +
    '?   id_token?: StringFilter | String,\n' +
    '?   session_state?: StringNullableFilter | String | Null,\n' +
    '?   user?: UserRelationFilter | UserWhereInput\n' +
    '  },\n' +
    '  select: {\n' +
    '    user: true\n' +
    '  }\n' +
    '}\n' +
    '\n' +
Unknown argument `provider_providerAccountId`. Did you mean `provider_providerACcountId`? Available options are marked with ?.
    at ti (C:Coding\project\node_modules\@prisma\client\runtime\library.js:118:5888)
    at si.handleRequestError (C:Coding\project\node_modules\@prisma\client\runtime\library.js:125:6473)
    at si.handleAndLogRequestError (C:Coding\project\node_modules\@prisma\client\runtime\library.js:125:6151)        
    at si.request (C:Coding\project\node_modules\@prisma\client\runtime\library.js:125:5859)
    at async l (C:Coding\project\node_modules\@prisma\client\runtime\library.js:130:10025)
    at async getUserByAccount (webpack-internal:///(rsc)/./node_modules/@next-auth/prisma-adapter/dist/index.js:222:29) :beginner: :100: {
name: 'GetUserByAccountError',
  code: undefined
}

If anything, this is all one bug, but due to the character limit I've split into multiple posts.
Thanks in advance to anyone who can help with this problem. 😉
@Ray it should be `provider_providerAccountId`
SiameseOP
It doesn't work, I tried replacing it in all files
did you run migrate?
@Ray did you run migrate?
SiameseOP
What do you mean in more detail?
when you update the schema, you need to run migration to update the table in database
and re-generate the prisma client
SiameseOP
I will try now
npx prisma migrate dev --name whatevernameyoulike
@Ray npx prisma migrate dev --name whatevernameyoulike
SiameseOP
I'm using mongodb and it doesn't work with it
SiameseOP
I solved the previous error, now the problem is ⬇️
[next-auth][debug][adapter_getUserByAccount] { args: [ { providerAccountId: '110691821', provider: 'github' } ] }
[next-auth][debug][adapter_getUserByAccount] { args: [ { providerAccountId: '110691821', provider: 'github' } ] }
[next-auth][debug][adapter_getUserByEmail] { args: [ 'my_mail@gmail.com' ] }
[next-auth][debug][adapter_createUser] {
  args: [
    {
      name: 'My_name',
      email: 'my_mail@gmail.com',
      image: 'https://avatars.githubusercontent.com/u/110691821?v=4',
      emailVerified: null
    }
  ]
}
[next-auth][debug][adapter_linkAccount] {
  args: [
    {
      provider: 'github',
      type: 'oauth',
      providerAccountId: '110691821',
      access_token: 'gho_oZWIJGV79H8qHGLODcrnVEKu1T0a8F1XNg8H',
      token_type: 'bearer',
      scope: 'read:user,user:email',
      userId: '6585fe27b818b32a88dadec7'
    }
  ]
}
[next-auth][error][adapter_error_linkAccount]
https://next-auth.js.org/errors#adapter_error_linkaccount
Invalid `prisma.account.create()` invocation:

{
  data: {
    provider: "github",
    type: "oauth",
    providerAccountId: "110691821",
    access_token: "gho_oZWIJGV79H8qHGLODcrnVEKu1T0a8F1XNg8H",
    token_type: "bearer",
    scope: "read:user,user:email",
    userId: "6585fe27b818b32a88dadec7",
+   id_token: String
  }
}
Argument `id_token` is missing. {
  message: '\n' +
    'Invalid `prisma.account.create()` invocation:\n' +
    '\n' +
    '{\n' +
    '  data: {\n' +
    '    provider: "github",\n' +
    '    type: "oauth",\n' +
    '    providerAccountId: "110691821",\n' +
    '    access_token: "gho_oZWIJGV79H8qHGLODcrnVEKu1T0a8F1XNg8H",\n' +
    '    token_type: "bearer",\n' +
    '    scope: "read:user,user:email",\n' +
    '    userId: "6585fe27b818b32a88dadec7",\n' +
    '+   id_token: String\n' +
    '  }\n' +
    '}\n' +
    '\n' +
    'Argument `id_token` is missing.',
  stack: 'PrismaClientValidationError: \n' +
    'Invalid `prisma.account.create()` invocation:\n' +
    '\n' +
    '{\n' +
    '  data: {\n' +
    '    provider: "github",\n' +
    '    type: "oauth",\n' +
    '    providerAccountId: "110691821",\n' +
    '    access_token: "gho_oZWIJGV79H8qHGLODcrnVEKu1T0a8F1XNg8H",\n' +
    '    token_type: "bearer",\n' +
    '    scope: "read:user,user:email",\n' +
    '    userId: "6585fe27b818b32a88dadec7",\n' +
    '+   id_token: String\n' +
    '  }\n' +
    '}\n' +
    '\n' +
'Argument `id_token` is missing.\n' +
    '    at ti (C:Coding\\project\\node_modules\\@prisma\\client\\runtime\\library.js:118:5888)\n' +
    '    at si.handleRequestError (C:Coding\\project\\node_modules\\@prisma\\client\\runtime\\library.js:125:6473)\n' +        
    '    at si.handleAndLogRequestError (C:Coding\\project\\node_modules\\@prisma\\client\\runtime\\library.js:125:6151)\n' +  
    '    at si.request (C:Coding\\project\\node_modules\\@prisma\\client\\runtime\\library.js:125:5859)\n' +
    '    at async l (C:Coding\\project\\node_modules\\@prisma\\client\\runtime\\library.js:130:10025)',
  name: 'PrismaClientValidationError'
}
[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: "110691821",
    access_token: "gho_oZWIJGV79H8qHGLODcrnVEKu1T0a8F1XNg8H",
    token_type: "bearer",
    scope: "read:user,user:email",
    userId: "6585fe27b818b32a88dadec7",
+   id_token: String
  }
SiameseOP
What you think about it ? @Ray
Pteromalid wasp
@Siamese did you manage to solve it
?
@Pteromalid wasp <@342322953486073866> did you manage to solve it
SiameseOP
I solved the first problem, but not the second.