---
title: "Recipe: Sign in with Apple and Google"
description: "@exact/sign-in is FedCM's identity request on @exact/passkeys' get (LLP 1133.014)."
modificationDate: "2026-11-25"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: Sign in with Apple and Google

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/sign-in: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

`@exact/sign-in` is FedCM's `identity` request on `@exact/passkeys`' `get`
(LLP 1133.014). The provider's ID token goes to your server; the plan never
sees it. `apps/auth-fixture` (`app.contract`, `app.ts`, `sign-in.mjs`) is
the whole app and server to copy from.

```prompt Add Sign in with Apple and Google
Add Sign in with Apple and Google to the Exact app in this folder. Use https://github.com/expo/exact/blob/main/docs/recipes/sign-in.md as the source for each step. The Exact checkout has the same page at docs/recipes/sign-in.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me. Find the Exact checkout (the folder with scripts/exact.mjs); if you cannot find it, ask me where it is.
2. Ask me which providers to offer, and for each one its client IDs (Apple's Services ID; Google's web client and iOS client) and my server's URL. If I have none yet, build against the test provider the recipe names (`packages/sign-in/test/idp.mjs`) and tell me so. Do not invent a client ID, and put no secret in the code.
3. Install the package: `bun <exact2>/scripts/exact.mjs add sign-in .`. Copy from `apps/auth-fixture` in the Exact checkout (`app.contract`, `app.ts`, `sign-in.mjs`).
4. In app.ts, write a grant line for each client and `net.fetch` for the server. Fetch a nonce when the screen shows, and call `get` at the press with nothing awaited before it. Post the credential without its `handle`, and fetch a fresh nonce after every request.
5. In app.contract, show the provider's own button (`exact-sign-in-button`) only while the provider is active; never draw the button yourself. Show nothing for `NetworkError`, `NotAllowedError` or `AbortError`. Sign out with `preventSilentAccess()`.
6. On the server, check the signature, `iss`, `aud`, `exp` and the nonce, once, as step 4 of the recipe says, and keep Apple's `user.name` the first time. For the web, add the return route of step 5.
7. Add tests in app.test.contract for a sign-in, a cancelled sign-in (`tap @t cancel`) and a sign-out. Under the agent, each request holds a `credential` ticket.
8. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 9) and report it; do not keep trying.
9. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
10. Tell me what you changed, what the tests and verify reported, and what I must still do before a real sign-in works: each client to register, and each line to change from the test provider to the real one.
```

1. **Grant** each client: `auth.apple <Services ID>`, `auth.google <web
   client>`, `auth.google <iOS client>`, and `net.fetch` for your server.

2. **Show the provider's own button** where the target offers it; never
   draw "Sign in with Apple" yourself.

   ```
   resource ids = getIdentityCapabilities() as shape IdentityCapabilities
   if ids.providers.apple.active
     exact-sign-in-button provider="apple" press=appleSignIn testId="apple-sign-in"
   ```

3. **Fetch a nonce when the screen shows; call `get` at the press** with
   nothing awaited before it (on the web the button holds the popup for
   it). Fetch a fresh nonce after every request.

   ```ts
   const credential = await credentials.get({ identity: { mode: 'active', providers: [{
     configURL: 'https://appleid.apple.com', clientId: 'com.example.web', params: { nonce },
     web: { redirectURI: `${api}/sign-in/return` },   // the web only
   }] } });
   const { handle, ...posted } = credential;          // post `posted`, never the handle
   ```

   Google's `configURL` is `https://accounts.google.com/gsi/fedcm.json`. Show
   nothing for `NetworkError`, `NotAllowedError` or `AbortError`.

4. **Verify** the signature with the provider's keys, `iss`, `aud`, `exp`
   and the single-use nonce issued to this client. Apple's native audience
   is the bundle ID. Google uses the web client on Android and the iOS client
   on Apple hosts. Keep Apple's `user.name` on the first sign-in.

5. **The web's return route** on your server takes Apple's `form_post` or
   Google's redirect (exchanging the code with your secret), keeps the ID
   token under a single-use, short-lived handle, and answers `303` to the
   page's `/.exact/auth/callback` with `state` and `relay=<handle>`. Redeem
   the handle once, then check as in step 4.

On the web, COOP makes popup closure unknowable: `openAuthSession` does not
report it as cancelled. Offer Cancel while pending (`signed = none` releases
the sign-in mutation for retry).

6. **Sign out** with `preventSilentAccess()`.

Under the agent a request holds a `credential` ticket naming the provider,
audience and nonce; `packages/sign-in/test/idp.mjs` signs what a provider
would, and `tap @t cancel` dismisses it.

Native Apple requests can run alone or beside a passkey: pass both
`publicKey` and passive `identity` to `get` for one system sheet.
Google on Apple is not implemented and its capabilities read false; use
[`@exact/oauth`](https://exact.expo.dev/recipes/oauth.md) through the system browser.
The `auth.apple` grant derives the signing
entitlement when the profile allows it. See [native sign-in](https://exact.expo.dev/learn/contract-for-agents/data-requests-and-side-effects.md#native-sign-in-exactsign-in)
for signing, nonce handling, result fields and current limits.
