Apple sign in scopes are not working #2745

Closed
opened 2026-03-13 10:17:16 -05:00 by GiteaMirror · 10 comments
Owner

Originally created by @Alvi24 on GitHub (Jan 21, 2026).

Originally assigned to: @bytaesu on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. setup betterAuth for apple signIn
  2. call this function in client(expo):
      return await authClient.signIn.social({
        provider: "apple",
        scopes: ["name", "email"],
        callbackURL: "/onboard",
      });

Current vs. Expected behavior

i have added the scopes for apple signIn (name and email) but after successful signIn user's email is set as name and not the actual apple account name

What version of Better Auth are you using?

1.4.9

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:45 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6030",
    "release": "25.2.0",
    "cpuCount": 11,
    "cpuModel": "Apple M3 Pro",
    "totalMemory": "18.00 GB",
    "freeMemory": "0.57 GB"
  },
  "node": {
    "version": "v24.11.0",
    "env": "development"
  },
  "packageManager": {
    "name": "bun",
    "version": "1.3.6"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "Unknown",
    "config": null
  }
}

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

Client, Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

trustedOrigins: [
"[appScheme]://",
"https://appleid.apple.com",
],
account: {
accountLinking: {
enabled: true,
},
},
database: authClient.adapter(ctx),
socialProviders: {
apple: {
clientId: process.env.APPLE_CLIENT_ID,
clientSecret: process.env.APPLE_CLIENT_SECRET,
appBundleIdentifier: process.env.APPLE_APP_BUNDLE_IDENTIFIER,
scope: ["name", "email"],
},

Originally created by @Alvi24 on GitHub (Jan 21, 2026). Originally assigned to: @bytaesu on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. setup betterAuth for apple signIn 2. call this function in client(expo): ``` return await authClient.signIn.social({ provider: "apple", scopes: ["name", "email"], callbackURL: "/onboard", }); ``` ### Current vs. Expected behavior i have added the scopes for apple signIn (name and email) but after successful signIn user's email is set as name and not the actual apple account name ### What version of Better Auth are you using? 1.4.9 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:45 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6030", "release": "25.2.0", "cpuCount": 11, "cpuModel": "Apple M3 Pro", "totalMemory": "18.00 GB", "freeMemory": "0.57 GB" }, "node": { "version": "v24.11.0", "env": "development" }, "packageManager": { "name": "bun", "version": "1.3.6" }, "frameworks": null, "databases": null, "betterAuth": { "version": "Unknown", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client, Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context trustedOrigins: [ "[appScheme]://", "https://appleid.apple.com", ], account: { accountLinking: { enabled: true, }, }, database: authClient.adapter(ctx), socialProviders: { apple: { clientId: process.env.APPLE_CLIENT_ID, clientSecret: process.env.APPLE_CLIENT_SECRET, appBundleIdentifier: process.env.APPLE_APP_BUNDLE_IDENTIFIER, scope: ["name", "email"], },
GiteaMirror added the expo label 2026-03-13 10:17:16 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 21, 2026):

It looks like you're experiencing an issue where the user's email is being set as the name instead of retrieving the actual account name during the Apple Sign In process with Better Auth.

Here are some potential troubleshooting steps you can follow:

  1. Check Your Configuration: Ensure that your Apple social provider configuration has both clientId and clientSecret correctly set up. Since you're working with Apple Sign In, remember that on native iOS, you should provide the app ID (bundle ID) as the client ID, rather than the service ID. If the service ID is used, it can cause the error you're experiencing [1].

  2. Verify OAuth Scopes: Make sure that the scopes you are requesting (["name", "email"]) are correctly set up and being respected during the sign-in process. If not, this might lead to incorrect data being returned.

  3. Test in a Different Environment: If possible, try testing the sign-in in both development and production environments to determine if the issue is specific to one. There have been reports of expected behaviors differing across these environments [1].

  4. Review Callbacks: Double-check that your callback URL is correctly configured and that it’s set to an HTTPS URL. Apple Sign In does not support localhost or non-HTTPS URLs for authentication flows [2].

If these steps don't resolve the issue, I recommend posting your question and tagging the Better Auth team members, @bekacru and @ping__, to get their insights directly!

What have you tried so far, and do you need any further assistance with the setup process?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Jan 21, 2026): It looks like you're experiencing an issue where the user's email is being set as the name instead of retrieving the actual account name during the Apple Sign In process with Better Auth. Here are some potential troubleshooting steps you can follow: 1. **Check Your Configuration**: Ensure that your Apple social provider configuration has both `clientId` and `clientSecret` correctly set up. Since you're working with Apple Sign In, remember that on native iOS, you should provide the app ID (bundle ID) as the client ID, rather than the service ID. If the service ID is used, it can cause the error you're experiencing [[1]](https://github.com/better-auth/better-auth/issues/7049). 2. **Verify OAuth Scopes**: Make sure that the scopes you are requesting (`["name", "email"]`) are correctly set up and being respected during the sign-in process. If not, this might lead to incorrect data being returned. 3. **Test in a Different Environment**: If possible, try testing the sign-in in both development and production environments to determine if the issue is specific to one. There have been reports of expected behaviors differing across these environments [[1]](https://github.com/better-auth/better-auth/issues/7049). 4. **Review Callbacks**: Double-check that your callback URL is correctly configured and that it’s set to an HTTPS URL. Apple Sign In does not support localhost or non-HTTPS URLs for authentication flows [[2]](https://www.better-auth.com/docs/authentication/apple). If these steps don't resolve the issue, I recommend posting your question and tagging the Better Auth team members, @bekacru and @ping__, to get their insights directly! What have you tried so far, and do you need any further assistance with the setup process? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@dosubot[bot] commented on GitHub (Jan 21, 2026):

This is a known issue in Better Auth versions before 1.4.12: if Apple doesn't provide a name (which only happens on the very first sign in), the provider falls back to using the email as the user's name. This is due to both Apple's API limitations and a bug in the callback handler that dropped the name during the redirect flow, especially in Expo/mobile scenarios. The bug was fixed in a recent release—upgrading to Better Auth 1.4.12 or later will resolve it. After the fix, if Apple doesn't provide a name, the name field will be blank (not set to the email) details & fix.

For Expo, make sure you use the @better-auth/expo plugin, your trustedOrigins includes your app scheme and https://appleid.apple.com, and you pass the idToken from the client to signIn.social({ provider: "apple", idToken }) for best results. If you still see issues after upgrading, double-check your session/cookie and idToken handling.

Note: Apple only provides the user's name on the very first authentication. If you need to persist the user's real name, you must store it on initial login—Apple will not send it again on subsequent logins Apple name field behavior.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 21, 2026): <!-- Answer --> This is a known issue in Better Auth versions before 1.4.12: if Apple doesn't provide a name (which only happens on the very first sign in), the provider falls back to using the email as the user's name. This is due to both Apple's API limitations and a bug in the callback handler that dropped the name during the redirect flow, especially in Expo/mobile scenarios. The bug was fixed in a recent release—upgrading to Better Auth 1.4.12 or later will resolve it. After the fix, if Apple doesn't provide a name, the name field will be blank (not set to the email) [details & fix](https://github.com/better-auth/better-auth/pull/7181). For Expo, make sure you use the `@better-auth/expo` plugin, your `trustedOrigins` includes your app scheme and `https://appleid.apple.com`, and you pass the `idToken` from the client to `signIn.social({ provider: "apple", idToken })` for best results. If you still see issues after upgrading, double-check your session/cookie and idToken handling. Note: Apple only provides the user's name on the very first authentication. If you need to persist the user's real name, you must store it on initial login—Apple will not send it again on subsequent logins [Apple name field behavior](https://github.com/better-auth/better-auth/issues/4153). <!-- 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/95f31b65-1fa6-468c-9629-b6acb3647470?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/95f31b65-1fa6-468c-9629-b6acb3647470?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/95f31b65-1fa6-468c-9629-b6acb3647470?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/95f31b65-1fa6-468c-9629-b6acb3647470?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/95f31b65-1fa6-468c-9629-b6acb3647470?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/95f31b65-1fa6-468c-9629-b6acb3647470?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/95f31b65-1fa6-468c-9629-b6acb3647470?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20issue%20in%20Better%20Auth%20versions%20before%201.4.12%3A%20if%20Apple%20doesn%27t%20provide%20a%20name%20%28which%20only%20happens%20on%20the%20very%20first%20sign%20in%29%2C%20the%20provider%20falls%20back%20to%20using%20the%20email%20as%20the%20user%27s%20name.%20This%20is%20due%20to%20both%20Apple%27s%20API%20limitations%20and%20a%20bug%20in%20the%20callback%20handler%20that%20dropped%20the%20name%20during%20the%20redirect%20flow%2C%20especially%20in%20Expo/mobile%20scenarios.%20The%20bug%20was%20fixed%20in%20a%20recent%20release%E2%80%94upgrading%20to%20Better%20Auth%201.4.12%20or%20later%20will%20resolve%20it.%20After%20the%20fix%2C%20if%20Apple%20doesn%27t%20provide%20a%20name%2C%20the%20name%20field%20will%20be%20blank%20%28not%20set%20to%20the%20email%29%C2%A0%5Bdetails%20%26%20fix%5D%28https%3A//github.com/better-auth/better-auth/pull/7181%29.%0A%0AFor%20Expo%2C%20make%20sure%20you%20use%20the%20%60%40better-auth/expo%60%20plugin%2C%20your%20%60trustedOrigins%60%20includes%20your%20app%20scheme%20and%20%60https%3A//appleid.apple.com%60%2C%20and%20you%20pass%20the%20%60idToken%60%20from%20the%20client%20to%20%60signIn.social%28%7B%20provider%3A%20%22apple%22%2C%20idToken%20%7D%29%60%20for%20best%20results.%20If%20you%20still%20see%20issues%20after%20upgrading%2C%20double-check%20your%20session/cookie%20and%20idToken%20handling.%0A%0ANote%3A%20Apple%20only%20provides%20the%20user%27s%20name%20on%20the%20very%20first%20authentication.%20If%20you%20need%20to%20persist%20the%20user%27s%20real%20name%2C%20you%20must%20store%20it%20on%20initial%20login%E2%80%94Apple%20will%20not%20send%20it%20again%20on%20subsequent%20logins%C2%A0%5BApple%20name%20field%20behavior%5D%28https%3A//github.com/better-auth/better-auth/issues/4153%29.)&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/7523)
Author
Owner

@dccarmo commented on GitHub (Jan 21, 2026):

https://github.com/better-auth/better-auth/pull/7181

@dccarmo commented on GitHub (Jan 21, 2026): https://github.com/better-auth/better-auth/pull/7181
Author
Owner

@bytaesu commented on GitHub (Jan 21, 2026):

Hi @Alvi24,

This has been fixed in the latest version. If the name is missing, it's masked as " ".
The name field will become optional in v1.5, so masking will also be removed!

@bytaesu commented on GitHub (Jan 21, 2026): Hi @Alvi24, This has been fixed in the latest version. If the name is missing, it's masked as `" "`. The name field will become optional in v1.5, so masking will also be removed!
Author
Owner

@Alvi24 commented on GitHub (Jan 22, 2026):

is this available in "better-auth": "1.4.17" ?

@Alvi24 commented on GitHub (Jan 22, 2026): is this available in "better-auth": "1.4.17" ?
Author
Owner

@iamibadd commented on GitHub (Jan 29, 2026):

@bytaesu is it available in 1.4.17?

@iamibadd commented on GitHub (Jan 29, 2026): @bytaesu is it available in 1.4.17?
Author
Owner

@hstemplewski commented on GitHub (Mar 4, 2026):

I am using the ID Token for apple login and in my case I got the email, but name is missing. Can someone help me how to get the name? Maybe I am missing something in the apple config?
server:

 apple: {
      clientId: env.APPLE_CLIENT_ID ?? '',
      clientSecret: env.APPLE_CLIENT_SECRET ?? '',
      appBundleIdentifier: env.APPLE_APP_BUNDLE_IDENTIFIER ?? '',
    },

expo app (using expo-apple-authentication):

const signInWithApple = useCallback(async () => {
    setIsLoading(true);
    try {
      const credential = await AppleAuthentication.signInAsync({
        requestedScopes: [
          AppleAuthentication.AppleAuthenticationScope.EMAIL,
          AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
        ],
      });

      if (!credential.identityToken) {
        throw new Error(t("auth.errors.signInFailed"));
      }

      await authClient.signIn.social(
        {
          provider: "apple",
          callbackURL: CALLBACK_URL,
          idToken: {
            token: credential.identityToken,
          },
          scopes: ["email", "name"],
        },
        {
          onSuccess: () => {
            router.replace("/(protected)/(tabs)");
          },
          onError: (error: ErrorContext) => {
            handleError(
              error.error?.message || t("auth.errors.signInFailed"),
              t("auth.errors.loginError"),
            );
          },
        },
      );
    } catch (error) {
      // Silently ignore user-initiated cancellation
      if (
        error instanceof Error &&
        "code" in error &&
        error.code === "ERR_REQUEST_CANCELED"
      ) {
        return;
      }
      handleError(
        error instanceof Error ? error.message : t("auth.errors.signInFailed"),
        t("common.error"),
      );
    } finally {
      setIsLoading(false);
    }
  }, [handleError, t]);
@hstemplewski commented on GitHub (Mar 4, 2026): I am using the ID Token for apple login and in my case I got the email, but name is missing. Can someone help me how to get the name? Maybe I am missing something in the apple config? server: ```ts apple: { clientId: env.APPLE_CLIENT_ID ?? '', clientSecret: env.APPLE_CLIENT_SECRET ?? '', appBundleIdentifier: env.APPLE_APP_BUNDLE_IDENTIFIER ?? '', }, ``` expo app (using expo-apple-authentication): ```ts const signInWithApple = useCallback(async () => { setIsLoading(true); try { const credential = await AppleAuthentication.signInAsync({ requestedScopes: [ AppleAuthentication.AppleAuthenticationScope.EMAIL, AppleAuthentication.AppleAuthenticationScope.FULL_NAME, ], }); if (!credential.identityToken) { throw new Error(t("auth.errors.signInFailed")); } await authClient.signIn.social( { provider: "apple", callbackURL: CALLBACK_URL, idToken: { token: credential.identityToken, }, scopes: ["email", "name"], }, { onSuccess: () => { router.replace("/(protected)/(tabs)"); }, onError: (error: ErrorContext) => { handleError( error.error?.message || t("auth.errors.signInFailed"), t("auth.errors.loginError"), ); }, }, ); } catch (error) { // Silently ignore user-initiated cancellation if ( error instanceof Error && "code" in error && error.code === "ERR_REQUEST_CANCELED" ) { return; } handleError( error instanceof Error ? error.message : t("auth.errors.signInFailed"), t("common.error"), ); } finally { setIsLoading(false); } }, [handleError, t]); ```
Author
Owner

@bytaesu commented on GitHub (Mar 4, 2026):

Hi @hstemplewski,

Could you let me know which version you are currently using?

@bytaesu commented on GitHub (Mar 4, 2026): Hi @hstemplewski, Could you let me know which version you are currently using?
Author
Owner

@hstemplewski commented on GitHub (Mar 4, 2026):

@bytaesu i am using 1.5.0

@hstemplewski commented on GitHub (Mar 4, 2026): @bytaesu i am using 1.5.0
Author
Owner

@bytaesu commented on GitHub (Mar 6, 2026):

Hi @hstemplewski,

Apple seems to need slightly different handling, so I've added a fix for that part. You will check the update in the next release!

@bytaesu commented on GitHub (Mar 6, 2026): Hi @hstemplewski, Apple seems to need slightly different handling, so I've added a fix for that part. You will check the update in the next release!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2745