[GH-ISSUE #1478] "Google OAuth sign-in not importing user's profile image" #26101

Closed
opened 2026-04-17 16:32:16 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @TariqueAnowar on GitHub (Feb 17, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1478

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Set up Google OAuth with valid credentials
  2. Configure better-auth with Google provider
  3. Sign in using the Google OAuth option
  4. Check user record in database - image field is null

Code Configuration

export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),
  socialProviders: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID as string,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
    },
  }
});

Database Schema

model User {
  id            String    @id
  name          String
  email         String
  emailVerified Boolean
  image         String?   // This field remains null after Google sign-in
  createdAt     DateTime
  updatedAt     DateTime
  // ... other fields
}

Current vs. Expected behavior

Expected: The user's Google profile image URL should be stored in the image field of the User record after successful Google OAuth authentication.

Actual: The image field remains null after successful Google OAuth authentication, while other fields like name and email are properly populated.

What version of Better Auth are you using?

1.1.18

Provide environment information

- better-auth version: 1.1.18
  - Database: PostgreSQL
  - Framework: Next.js 15.1.6
  - Node.js version: [Your Node.js version]

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { admin } from "better-auth/plugins";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from "./prisma-client";
import emailService from "@/services/email.service";

export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),
  emailAndPassword: {
    enabled: true,
  },
  socialProviders: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID as string,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
    },
  },
  emailVerification: {
    sendVerificationEmail: async ({ user, url, token }, request) => {
      await emailService.sendVerificationEmail(user.email, url);
    },
  },
  plugins: [admin({ impersonationSessionDuration: 60 * 60 })],
});

Additional context

The issue can be observed in localhost, i have not tried on production or live domain.

Originally created by @TariqueAnowar on GitHub (Feb 17, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1478 ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce 1. Set up Google OAuth with valid credentials 2. Configure better-auth with Google provider 3. Sign in using the Google OAuth option 4. Check user record in database - image field is null ### Code Configuration ```typescript export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, }, } }); ``` ### Database Schema ```prisma model User { id String @id name String email String emailVerified Boolean image String? // This field remains null after Google sign-in createdAt DateTime updatedAt DateTime // ... other fields } ``` ### Current vs. Expected behavior Expected: The user's Google profile image URL should be stored in the `image` field of the User record after successful Google OAuth authentication. Actual: The `image` field remains null after successful Google OAuth authentication, while other fields like name and email are properly populated. ### What version of Better Auth are you using? 1.1.18 ### Provide environment information ```bash - better-auth version: 1.1.18 - Database: PostgreSQL - Framework: Next.js 15.1.6 - Node.js version: [Your Node.js version] ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { admin } from "better-auth/plugins"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { prisma } from "./prisma-client"; import emailService from "@/services/email.service"; export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), emailAndPassword: { enabled: true, }, socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, }, }, emailVerification: { sendVerificationEmail: async ({ user, url, token }, request) => { await emailService.sendVerificationEmail(user.email, url); }, }, plugins: [admin({ impersonationSessionDuration: 60 * 60 })], }); ``` ### Additional context The issue can be observed in localhost, i have not tried on production or live domain.
GiteaMirror added the lockedbug labels 2026-04-17 16:32:16 -05:00
Author
Owner

@Kinfe123 commented on GitHub (Feb 18, 2025):

Is the user signed up already tho ?

<!-- gh-comment-id:2664968892 --> @Kinfe123 commented on GitHub (Feb 18, 2025): Is the user signed up already tho ?
Author
Owner

@TariqueAnowar commented on GitHub (Feb 18, 2025):

Yes. name, email, access-token, scope everything storing perfectly except 'image' field.

<!-- gh-comment-id:2666360811 --> @TariqueAnowar commented on GitHub (Feb 18, 2025): Yes. name, email, access-token, scope everything storing perfectly except 'image' field.
Author
Owner

@notm1ke commented on GitHub (Feb 23, 2025):

@TariqueAnowar - just ran into this as well. Not sure if you figured it on your own, but this is what I did to solve it: try remapping the Prisma User model's table name from user to something else like profile using @@map, and then run a migration. Looks like the user table may be reserved by Postgres.

If it still doesn't work after that, make sure the privacy settings on your Google account allow anyone to see your profile picture, as it might not be returned due to that. (If you are part of a Google Workspace org, make sure that you (1) have permission to modify your profile in Google Admin, and (2) that your privacy settings are configured correctly - the Stack Overflow link I sent shows how to do this)

<!-- gh-comment-id:2677086444 --> @notm1ke commented on GitHub (Feb 23, 2025): @TariqueAnowar - just ran into this as well. Not sure if you figured it on your own, but this is what I did to solve it: try remapping the Prisma User model's table name from `user` to something else like `profile` using `@@map`, and then run a migration. Looks like the `user` table may be reserved by Postgres. If it still doesn't work after that, make sure the [privacy settings](https://stackoverflow.com/a/77910756) on your Google account allow anyone to see your profile picture, as it might not be returned due to that. (If you are part of a Google Workspace org, make sure that you (1) have permission to modify your profile in Google Admin, and (2) that your privacy settings are configured correctly - the Stack Overflow link I sent shows how to do this)
Author
Owner

@mfragale commented on GitHub (Mar 31, 2025):

Same issue happens when linking an existing user to a generic auth provider. When I try linking an existing user using client.oauth2.link the user info I get from my OAuth provider contains a image parameter but that info never gets updated in my user image field in my db.

<!-- gh-comment-id:2767221181 --> @mfragale commented on GitHub (Mar 31, 2025): Same issue happens when linking an existing user to a generic auth provider. When I try linking an existing user using client.oauth2.link the user info I get from my OAuth provider contains a image parameter but that info never gets updated in my user image field in my db.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26101