Skip to main content

Signing in

AppleSignIn.signIn(options?) shows Apple's sign-in sheet and resolves an AppleCredential, or undefined when the user cancels.

const credential = await AppleSignIn.signIn({
scopes: ['fullName', 'email'],
nonce: rawNonce,
state: requestId,
})

Options​

OptionTypeEffect
scopesAppleSignInScope[]'fullName' and/or 'email'. Defaults to none: Apple then returns only the user ID and tokens.
noncestringRaw, random, single-use. Hashed with SHA-256 before it goes to Apple.
statestringOpaque value returned unchanged in credential.state, to match the response to the request.

All options are optional; signIn() with no argument asks for no scopes.

Email and name arrive once​

Apple returns email and fullName only the first time a user signs in to your app. Later sign-ins leave both undefined, even with the scopes requested. Store them, or send them to your backend, as soon as you receive them.

:::warning Store first-sign-in data immediately If you drop the email or name on the first sign-in, later sign-ins will not bring them back. :::

  • email may be a private relay address ending in @privaterelay.appleid.com.
  • fullName is undefined when every name component is empty, which is what Apple returns after the first sign-in.

The credential​

FieldMeaning
userStable user ID, the sub claim of the ID token. Same on every device for apps of one developer team.
identityTokenOpenID Connect ID token (JWT). Verify it on your backend.
authorizationCodeShort-lived, single-use code your backend exchanges with Apple for refresh tokens.
realUserStatuslikelyReal, unknown or unsupported.
stateThe state you passed.
email, fullNameFirst sign-in only, when the scope was requested.

Save user: it is the key for getCredentialState.

Cancellation​

Closing the sheet resolves undefined. Only real failures reject.

const credential = await AppleSignIn.signIn()
if (credential === undefined) return // user cancelled

One sign-in at a time​

Only one sign-in runs at a time. A call made while the sheet is showing rejects with IN_PROGRESS. Guard your button against double taps, as the example button does.

Presentation​

The sheet is presented from the window of the top-most view controller of the foreground key window. When there is none, for example while the app is in the background, signIn rejects with NO_PRESENTER.