Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Typeorm-legacy. Login with Google Account: ER_DATA_TOO_LONG: Data too long for column 'id_token' at row #3825

Closed
hejamartin opened this issue Sep 17, 2021 · 7 comments · May be fixed by nextauthjs/adapters#336
Labels
adapters Changes related to the core code concerning database adapters enhancement New feature or request

Comments

@hejamartin
Copy link

Issue regarding the typeorm-legacy default entity model

This is the error I got.
The entity for this database field "id_token" is a varchar, which is capped on 255 characters.

This happens when:
When trying to sign in with my Google Account, the id_token is 1054 characters.

So the type of that field should be "text" or equivalent. I am not great at all when it comes to databases.

@balazsorban44
Copy link
Member

The options here:

  1. You could override the default model to support longer strings https://next-auth.js.org/adapters/typeorm#custom-models
  2. Change to Prisma and use the steps from nextauthjs/adapters#223
  3. We have to change the type in @next-auth/typeorm-legacy-adapter to support longer strings by default

Personally, I think the quickest fix for you would be to try out the @next-auth/prisma-adapter and go with option 2, especially if you don't usually work with databases. When implementing these adapters, I found myself having a much better time with Prisma, and I don't have a lot of experience with databases either.

I will discuss further with @ndom91 if we should take any steps on our side here.

@balazsorban44 balazsorban44 added typeorm enhancement New feature or request labels Sep 17, 2021
@hejamartin
Copy link
Author

Yeah. I experienced other problems and had to resolve other things with typeorm with some workarounds.

Didn't get that mysql also was able to be dealing with, when it comes to Prisma.
I will revert and use Prisma, since I guess it is a little neater and perhaps more straightforward.

The general solution to the id_token seems to jsut change the type in other adapters.. easily done. ;)
Thx

@ndom91
Copy link
Member

ndom91 commented Sep 17, 2021

Hey @hejamartin I'd be curious, are you requesting additional scopes from Google? Or are you using the default ones? Just trying to figure out how your id_token from Google got so large haha

@hejamartin
Copy link
Author

Hi @ndom91
I wish I could say something smart. But I cant.

But no - only those scopes that are bare minimum - email and profile.
I made an OAUTH-app for external use. And added my custom domain google-email [email protected] as a test-user.

Thx for the v4 beta work you are doing ya all!

@ndom91
Copy link
Member

ndom91 commented Sep 17, 2021

Hmm okay strange. I'll take a closer look at this then, if the Google jwt /id_token is always this large then yeah we definitely need to bump up that field size / type 👍

@kushthakker
Copy link

I am still having this issue on "@next-auth/prisma-adapter": "^0.5.2-next.19" and "next-auth": "^4.0.0-beta.6". I tried this

model Account {
  id                 String  @id @default(cuid())
  userId             String
  type               String
  provider           String
  providerAccountId  String
  refresh_token      String?
  access_token       String?
  expires_at         Int?
  token_type         String?
  scope              String?
  id_token           String?  @db.Text
  session_state      String?
  oauth_token_secret String?
  oauth_token        String?

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

by adding @db.Text but it's still showing same error.

thgh referenced this issue in thgh/adapters Dec 5, 2021
@ndom91 ndom91 transferred this issue from nextauthjs/adapters Feb 4, 2022
@ndom91 ndom91 added the adapters Changes related to the core code concerning database adapters label Feb 4, 2022
@ndom91
Copy link
Member

ndom91 commented Feb 4, 2022

nextauthjs/next-auth has been migrated to a monorepository. The adapters code can now be found there under packages/adapter-*. Thanks for your interest in the project!

@nextauthjs nextauthjs locked and limited conversation to collaborators Feb 12, 2022
@balazsorban44 balazsorban44 converted this issue into discussion #3955 Feb 12, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
adapters Changes related to the core code concerning database adapters enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants