Social sign in: Better Auth Error: invalid_code #1253

Closed
opened 2026-03-13 08:30:07 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @Sleepful on GitHub (May 23, 2025).

Trying to sign in with Google OAuth, it walks me through the google auth screen fine, I select my google account, but it errors when it redirects back to my local page:

Image

On the server terminal it shows:

2025-05-23T08:34:34.046Z ERROR [Better Auth]:  {
  error: 'invalid_client',
  error_description: 'Unauthorized',
  status: 401,
  statusText: 'Unauthorized'
}

This is very cryptic and I cannot understand why it is happening. All configuration is set per the instructions.

Originally created by @Sleepful on GitHub (May 23, 2025). Trying to sign in with Google OAuth, it walks me through the google auth screen fine, I select my google account, but it errors when it redirects back to my local page: <img width="718" alt="Image" src="https://github.com/user-attachments/assets/4d4b46e2-063c-42e5-a50e-3a0f6ce883e5" /> On the server terminal it shows: ```sh 2025-05-23T08:34:34.046Z ERROR [Better Auth]: { error: 'invalid_client', error_description: 'Unauthorized', status: 401, statusText: 'Unauthorized' } ``` This is very cryptic and I cannot understand _why_ it is happening. All configuration is set per the instructions.
Author
Owner

@Sleepful commented on GitHub (May 23, 2025):

Might be this error:

a12b7fc331/packages/better-auth/src/api/routes/callback.ts (L102)

@Sleepful commented on GitHub (May 23, 2025): Might be this error: https://github.com/better-auth/better-auth/blob/a12b7fc331443bdbf1cc150c6a21ec38ddbf5428/packages/better-auth/src/api/routes/callback.ts#L102
Author
Owner

@Sleepful commented on GitHub (May 23, 2025):

it was a typo with my credentials... 🤦‍♀

https://stackoverflow.com/questions/17166848/invalid-client-in-google-oauth2

@Sleepful commented on GitHub (May 23, 2025): it was a typo with my credentials... 🤦‍♀ https://stackoverflow.com/questions/17166848/invalid-client-in-google-oauth2
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1253