Skip to content

feat(google): populate given_name, family_name, and locale in user metadata#2501

Open
akremer wants to merge 1 commit intosupabase:masterfrom
akremer:fix/google-given-family-name-locale
Open

feat(google): populate given_name, family_name, and locale in user metadata#2501
akremer wants to merge 1 commit intosupabase:masterfrom
akremer:fix/google-given-family-name-locale

Conversation

@akremer
Copy link
Copy Markdown

@akremer akremer commented Apr 23, 2026

Summary

Google's OIDC ID token includes given_name, family_name, and locale as standard claims, but the Google provider silently drops them. The Claims struct already has fields for all three (GivenName, FamilyName, Locale) and the LinkedIn provider correctly populates them — but the Google provider never did.

This PR:

  • Adds GivenName, FamilyName, and Locale fields to the googleUser struct so they are deserialized from the ID token / userinfo response
  • Maps them into Claims metadata in both parseGoogleIDToken (ID token path) and GetUserData (legacy userinfo endpoint fallback)
  • Also populates Email and EmailVerified in parseGoogleIDToken, which were previously missing from the ID token path (the legacy path already had them)
  • Updates test fixtures to include the new fields

Root Cause

Two issues:

  1. googleUser struct missing fields (google.go L13–L23) — the struct had no given_name, family_name, or locale JSON tags, so Go's json.Unmarshal silently discarded them.

  2. parseGoogleIDToken never mapped them (oidc.go L68–L99) — even if the struct had the fields, the Claims metadata construction only set Name, Picture, AvatarURL, FullName, and ProviderId.

The LinkedIn provider (parseLinkedinIDToken in the same file) demonstrates the correct pattern — its claims struct includes these fields and maps them into Claims.

Impact

Every Supabase project using Google OAuth is affected. raw_user_meta_data is permanently missing structured name data that Google provides. Applications needing first/last name must resort to unreliable string splitting of full_name.

Related

…tadata

Google's OIDC ID token includes given_name, family_name, and locale as
standard claims, but the Google provider was silently dropping them. The
Claims struct already has fields for these (used by LinkedIn), but the
googleUser struct lacked the corresponding JSON fields and
parseGoogleIDToken never mapped them.

This adds the missing fields to googleUser and maps them in both the
ID token path (parseGoogleIDToken) and the legacy userinfo endpoint
fallback (GetUserData), matching the pattern used by the LinkedIn
provider.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@akremer akremer requested a review from a team as a code owner April 23, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant