Sign in with Apple
This guide teaches you how to add native Sign in with Apple to your Clerk apps on Apple platforms.
Configure with Clerk CLI (recommended)
From your Xcode project or workspace directory, run the Clerk CLI with npx and choose to enable native Sign in with Apple:
npx clerk@latest initThe CLI adds the Apple entitlement, registers your native app, and enables Native API and Apple sign-in on the linked development instance. Existing hosted Apple credentials are preserved. To add Apple sign-in after an earlier setup, run npx clerk@latest init --sign-in-with-apple.
The CLI reads your Bundle ID and uses the App ID Prefix from a matching Clerk registration or, otherwise, your project's signing team, which is usually the same. If it asks for a prefix, copy App ID Prefix from your app's identifier in the Apple Developer portal; it's usually your Apple Team ID.
Clerk needs a registration for every Bundle ID your apps sign in with, including when a target builds with a different Bundle ID on each platform. clerk init registers the Bundle ID of the target you choose and saves it on the Apple social connection. It stops if you rerun clerk init --sign-in-with-apple for another Bundle ID. For each additional Bundle ID, add the app on the Native applications page of the same Clerk application and development instance. Then add the Sign in with Apple capability to every target that signs in.
For a customized app, finish any remaining Swift integration with the iOS Quickstart
Add your native application
On the Native applications page in the Clerk Dashboard, enable the Native API, then add your iOS application. You will need your iOS app's App ID Prefix and Bundle ID.
To add an app for another Apple platform, such as macOS, select the iOS tab and select Add iOS app. If your apps have different Bundle IDs, add each one. If they share a Bundle ID, add it once. After you complete the remaining steps, Sign in with Apple works in each app.
Enable Apple as a social connection
- In the Clerk Dashboard, navigate to the SSO connections page.
- Select Add connection and select For all users.
- Select Apple from the provider list.
- Ensure that Enable for sign-up and sign-in is toggled on.
- At the top of the page, select Enable connection.
Build your sign-in flow
Use clerk.auth.signInWithApple() to start the native Sign in with Apple flow:
try await clerk.auth.signInWithApple()signInWithApple() creates the request to Apple and sets its nonce, a random single-use value that Apple copies into the ID token. If you create your own ASAuthorizationAppleIDRequest and pass its ID token to signInWithIdToken(_:provider:)nonce to a random value first. Without a nonce, Clerk can reject the token with an authorization_invalid error.
Configure your production instance
clerk init configures only the linked development instance. For production, add each app's exact App ID Prefix and Bundle ID registration to the production instance, enable the Native API, enable Apple as a social connection, configure the Release build with the production , and add the production associated domain to its entitlements path. A native-only Apple flow still doesn't need hosted Apple credentials.
clerk deploy and clerk deploy status check the Clerk side of this setup. For a native-only Apple flow, they count native Sign in with Apple as configured once the production instance has a registration for the Bundle ID saved on the Apple social connection, Native API is enabled, and Apple is enabled. Until then, they explain what's missing and link to the production instance's Native applications page. They don't check your other apps, so confirm that each one is registered on the production instance too. If the Apple social connection also has hosted Apple credentials, they don't check the native setup, so confirm on the production instance's Native applications page that Native API is enabled and each app is registered.
Run clerk doctor to check your Release configuration's native registration (Bundle ID and App ID Prefix), associated domain, and, when it can be read, Publishable Key against production. It also checks that Native API is enabled on the production instance. Pass --xcode-configuration <name> to check another non-Debug configuration.
Troubleshooting
I’m not receiving the user’s first and last name from Apple
Apple only provides fullName the very first time a user authorizes your app with Sign in with Apple. On subsequent sign-ins (or if the user already authorized your app in the past), Apple does not resend the name.
If you expected a name and didn’t receive one, check the following:
- First-time authorization only: If this isn’t the user’s first authorization for this app, Apple will not return
fullName. You should store the name the first time you receive it and treat it as optional after that. Deleting the user from Clerk does not reset this on Apple’s side. - Requested scopes: Make sure your Sign in with Apple request includes the
fullNamescope (andemail, if you need it). IffullNamewasn’t requested, Apple won’t prompt the user to share it. - User denied name sharing: If the user chooses not to share their name, Apple won’t provide it. Make sure your UI can collect a name as a fallback.
To test the first-time flow again, delete the user from Clerk, revoke the app's authorization using the steps for your platform below, then sign in again:
- iOS: Go to Settings → your name → Sign in with Apple → your app or developer → Delete.
- macOS: Go to System Settings → your name → Sign in with Apple and stop using Sign in with Apple for your app or developer.
Revoking authorization resets your app and any apps grouped with it under one primary App ID for Sign in with Apple. Revoke other apps separately.
Feedback
Last updated on