This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

Expo AppleAuthentication

A library that provides Sign-in with Apple capability for iOS.

iOS
tvOS
Included in Expo Go
Recommended version:
~56.0.4

expo-apple-authentication provides Apple authentication for iOS. It does not yet support Android or web.

Any app that includes third-party authentication options must provide Apple authentication as an option to comply with App Store Review guidelines. For more information, see Apple authentication on the Sign In with Apple website.

Installation

Terminal
- npx expo install expo-apple-authentication
- yarn expo install expo-apple-authentication
- pnpm expo install expo-apple-authentication
- bun expo install expo-apple-authentication

If you are installing this in an existing React Native app, make sure to install expo in your project.

Configuration in app config

You can configure expo-apple-authentication using its built-in config plugin if you use config plugins in your project (Continuous Native Generation (CNG)). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect. If your app does not use CNG, then you'll need to manually configure the library.

Setup iOS project

To enable the Sign In with Apple capability in your app, set the ios.usesAppleSignIn property to true in your project's app config:

app.json
{ "expo": { "ios": { "usesAppleSignIn": true } } }

Example app.json with config plugin

Running EAS Build locally will use iOS capabilities signing to enable the required capabilities before building.

app.json
{ "expo": { "plugins": ["expo-apple-authentication"] } }
Are you using this library in an existing React Native app?

Apps that don't use EAS Build must manually configure the Apple Sign In capability for their bundle identifier.

If you enable the Apple Sign In capability through the Apple Developer Console, then be sure to add the following entitlements in your ios/[app]/[app].entitlements file:

<key>com.apple.developer.applesignin</key> <array> <string>Default</string> </array>

Also, set CFBundleAllowMixedLocalizations to true in your ios/[app]/Info.plist to ensure the sign-in button uses the device locale.

Usage

Apple Authentication Usage
import * as AppleAuthentication from 'expo-apple-authentication'; import { View, StyleSheet } from 'react-native'; export default function App() { return ( <View style={styles.container}> <AppleAuthentication.AppleAuthenticationButton buttonType={AppleAuthentication.AppleAuthenticationButtonType.SIGN_IN} buttonStyle={AppleAuthentication.AppleAuthenticationButtonStyle.BLACK} cornerRadius={5} style={styles.button} onPress={async () => { try { const credential = await AppleAuthentication.signInAsync({ requestedScopes: [ AppleAuthentication.AppleAuthenticationScope.FULL_NAME, AppleAuthentication.AppleAuthenticationScope.EMAIL, ], }); // signed in } catch (e) { if (e.code === 'ERR_REQUEST_CANCELED') { // handle that the user canceled the sign-in flow } else { // handle other errors } } }} /> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', }, button: { width: 200, height: 44, }, });

Development and testing

You can test this library in Expo Go on iOS without following any of the instructions above. However, you'll need to add the config plugin to use this library if you are using EAS Build. When you sign into Expo Go, the identifiers and values you receive will likely be different than what you'll receive in standalone apps.

You can do limited testing of this library on the iOS Simulator. However, not all methods will behave the same as on a device, so we highly recommend testing on a real device when possible while developing.

Verifying the Response from Apple

Apple's response includes a signed JWT with information about the user. To ensure that the response came from Apple, you can cryptographically verify the signature with Apple's public key, which is published at https://appleid.apple.com/auth/keys. This process is not specific to Expo.

API

import * as AppleAuthentication from 'expo-apple-authentication';

No API data file found, sorry!

Error codes

Most of the error codes match the official Apple Authorization errors.

CodeDescription
ERR_INVALID_OPERATIONAn invalid authorization operation has been performed.
ERR_INVALID_RESPONSEThe authorization request received an invalid response.
ERR_INVALID_SCOPEAn invalid AppleAuthenticationScope was passed in.
ERR_REQUEST_CANCELEDThe user canceled the authorization attempt.
ERR_REQUEST_FAILEDThe authorization attempt failed. See the error message for additional information.
ERR_REQUEST_NOT_HANDLEDThe authorization request wasn't correctly handled.
ERR_REQUEST_NOT_INTERACTIVEThe authorization request isn't interactive.
ERR_REQUEST_UNKNOWNThe authorization attempt failed for an unknown reason.