[GH-ISSUE #1476] Google OAuth sign-in not importing user's profile image #17407

Closed
opened 2026-04-15 15:32:40 -05:00 by GiteaMirror · 0 comments
Owner

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

To Reproduce

When signing in with Google OAuth, the user's profile image is not being imported into the user record. The image field remains null in the database after successful authentication.

Steps 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
```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 Behavior
The user's Google profile image URL should be stored in the `image` field of the User record after successful Google OAuth authentication.

### Actual Behavior
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
### Environment
- 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

Additional Context

I am currently testing google Oauth in localhost (maybe this is the reason)

Originally created by @TariqueAnowar on GitHub (Feb 17, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1476 ### To Reproduce When signing in with Google OAuth, the user's profile image is not being imported into the user record. The `image` field remains null in the database after successful authentication. ### Steps 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 Behavior The user's Google profile image URL should be stored in the `image` field of the User record after successful Google OAuth authentication. ### Actual Behavior 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 ### Environment - 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 ### Additional Context I am currently testing google Oauth in localhost (maybe this is the reason)
GiteaMirror added the lockedbug labels 2026-04-15 15:32:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#17407