[GH-ISSUE #4153] Sign in with Apple: Name is not present in mapProfileToUser #9840

Closed
opened 2026-04-13 05:36:19 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @liri2006 on GitHub (Aug 22, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4153

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Configure Sign in with Apple
  2. Create account

Current vs. Expected behavior

Expected: Profile object in mapProfileToUser contains name.
Current: Name is undefined

What version of Better Auth are you using?

1.3.7

System info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 4.86 GB / 31.77 GB
  Browsers:
    Edge: Chromium (139.0.3405.102)
    Internet Explorer: 11.0.26100.1882

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
 apple: {
      clientId: process.env.APPLE_ID as string,
      clientSecret: process.env.APPLE_SECRET as string,
      appBundleIdentifier: process.env.APPLE_APP_BUNDLE_IDENTIFIER as string,
      scope: ['email', 'name'],
      mapProfileToUser: (profile) => {
        console.log(profile)
        return {
          full_name: profile?.user?.name ?? profile?.name,
        }
      },
    },
});

Additional context

Tested with deleting existing account in Apple settings, as Apple send user data only on initial log in.

Originally created by @liri2006 on GitHub (Aug 22, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4153 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Configure Sign in with Apple 2. Create account ### Current vs. Expected behavior Expected: Profile object in mapProfileToUser contains name. Current: Name is undefined ### What version of Better Auth are you using? 1.3.7 ### System info ```bash System: OS: Windows 11 10.0.26100 CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz Memory: 4.86 GB / 31.77 GB Browsers: Edge: Chromium (139.0.3405.102) Internet Explorer: 11.0.26100.1882 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ apple: { clientId: process.env.APPLE_ID as string, clientSecret: process.env.APPLE_SECRET as string, appBundleIdentifier: process.env.APPLE_APP_BUNDLE_IDENTIFIER as string, scope: ['email', 'name'], mapProfileToUser: (profile) => { console.log(profile) return { full_name: profile?.user?.name ?? profile?.name, } }, }, }); ``` ### Additional context Tested with deleting existing account in Apple settings, as Apple send user data only on initial log in.
GiteaMirror added the locked label 2026-04-13 05:36:19 -05:00
Author
Owner

@himself65 commented on GitHub (Aug 22, 2025):

Hi, can you open a PR for this? seems like you already have solution

<!-- gh-comment-id:3213882804 --> @himself65 commented on GitHub (Aug 22, 2025): Hi, can you open a PR for this? seems like you already have solution
Author
Owner

@dosubot[bot] commented on GitHub (Aug 22, 2025):

Hi @liri2006! I'm Dosu and I’m helping the better-auth team.

This is expected behavior with Sign in with Apple: Apple only provides the user's name on the very first authentication, and not on subsequent logins—even if you delete the account and re-authenticate, Apple may not always resend the name field. Better Auth's implementation tries to extract the name from the idToken or userInfo endpoint and passes it to mapProfileToUser, but if Apple doesn't include the name, it will be undefined in the profile object you receive. This is a limitation of Apple's OAuth flow, not a bug in Better Auth. If you need to ensure the name is captured, you must store it on initial login, as you won't be able to retrieve it again from Apple later. For more details, see the relevant code and extraction logic.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3213890378 --> @dosubot[bot] commented on GitHub (Aug 22, 2025): <!-- Greeting --> Hi @liri2006! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is expected behavior with Sign in with Apple: Apple only provides the user's name on the very first authentication, and not on subsequent logins—even if you delete the account and re-authenticate, Apple may not always resend the name field. Better Auth's implementation tries to extract the name from the idToken or userInfo endpoint and passes it to mapProfileToUser, but if Apple doesn't include the name, it will be undefined in the profile object you receive. This is a limitation of Apple's OAuth flow, not a bug in Better Auth. If you need to ensure the name is captured, you must store it on initial login, as you won't be able to retrieve it again from Apple later. For more details, see the [relevant code and extraction logic](https://github.com/better-auth/better-auth/blob/fe9c5e428b0a11ec3217bf9c66db978cf54f7ad8/packages/better-auth/src/plugins/generic-oauth/index.ts). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/e85dddd5-2d90-4160-86d0-61e71f3f1246?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/e85dddd5-2d90-4160-86d0-61e71f3f1246?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/e85dddd5-2d90-4160-86d0-61e71f3f1246?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/e85dddd5-2d90-4160-86d0-61e71f3f1246?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e85dddd5-2d90-4160-86d0-61e71f3f1246?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/e85dddd5-2d90-4160-86d0-61e71f3f1246?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e85dddd5-2d90-4160-86d0-61e71f3f1246?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4153)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9840