# Let people sign in with Apple on your website

> Use AirHost's sign-in, or have an Agent register a Services ID, set your website's domains and return URLs, and make the Sign in with Apple key your server needs.

Source: https://air.build/docs/build/let-people-sign-in-with-apple-on-your-website/

Sign in with Apple on a website works through a Services ID on your Apple team: it names your website to Apple, lists the domains it runs on and the return URLs Apple sends people back to, and is tied to your app's App ID. Your website's server also needs a Sign in with Apple key. Your Agents set up most of it; one step is yours, in your Apple Developer account.

> [!NOTE]
> Apple's [Register a Services ID](https://developer.apple.com/help/account/identifiers/register-a-services-id/) and [Create a private key to access a service](https://developer.apple.com/help/account/keys/create-a-private-key/) pages say a Services ID and a key need the Account Holder or Admin role in your Apple Developer team.

> [!NOTE]
> This page is about your website. For Sign in with Apple inside your app, see [Turn on iCloud, App Groups or another capability](https://air.build/docs/build/turn-on-an-app-capability/). AirBuild has no screen for Services IDs or Sign in with Apple keys: you ask an Agent in the Project's chat, and it uses `asc web service-ids` and `asc web sign-in-keys` (see [asc: web session commands](https://air.build/docs/cli/asc-web/#subcommands)). These commands use the Team owner's Apple sign-in that AirBuild keeps.

## If your website runs on AirHost

AirHost, AirBuild's hosting for your app, has sign-in of its own. While your app has no sign-in yet, the **App Users** tab says **Add Sign-In to This App**, with "Sign in with Apple and Google, ready to use". Once the app uses it, the people who sign in are listed there. To add it, tap **Ask Agents to Add** on that tab, or ask in the chat. See [Host your app's backend, database and sign-in (AirHost)](https://air.build/docs/services/host-a-backend/#ask-your-agents-to-set-it-up).

The rest of this page sets up Sign in with Apple under your own Apple team, for a website whose sign-in you run yourself.

## Before you start

- The Team's owner has connected an Apple Developer account and switched a team on. See [Connect your Apple Developer account](https://air.build/docs/app-store/connect-apple-developer-account/).
- Sign in with Apple is turned on for your app's App ID. If it isn't, ask "Turn on Sign in with Apple for the app." See [Turn on iCloud, App Groups or another capability](https://air.build/docs/build/turn-on-an-app-capability/).
- You know your website's domain, such as `example.com`, and its return URL, the address Apple sends people back to after they sign in, such as `https://example.com/auth/apple/callback`. Whoever writes the website's sign-in code decides the return URL.
- You can sign in to your Apple Developer account on the web, for one step.

## Register a Services ID

Ask in the Project's chat, for example:

```text
Register a Services ID for Sign in with Apple on our website, called "Notes Web", with the identifier com.example.notes.web.
```

The Agent registers it with `asc web service-ids create`. The command runs only with `--confirm`, because it changes your Apple Developer account, so the Agent asks you first. Your website's sign-in code uses the identifier, so note it.

The new Services ID has nothing turned on yet. The command's help says to configure Sign in with Apple for it in the Developer Portal, which is the next step.

## Turn on Sign in with Apple for it

`asc` can't do this step; you do it in your Apple Developer account on the web. Apple's [Configure Sign in with Apple for the web](https://developer.apple.com/help/account/capabilities/configure-sign-in-with-apple-for-the-web/) page walks through it: open the Services ID, turn on Sign in with Apple, choose your app's App ID as its primary App ID, and enter your website's domains and return URLs.

## Set the domains and return URLs

To check the domains and return URLs, or to change them later, ask, for example:

```text
Set the Sign in with Apple domains for com.example.notes.web to example.com and www.example.com, with the return URL https://example.com/auth/apple/callback.
```

The Agent uses `asc web service-ids domains set`. It replaces both lists with what you give it, so name every domain and return URL you want to keep, not only the new ones. It runs only with `--confirm`, so the Agent asks you first. It keeps the primary App ID as it is, and reports success only once a fresh read shows the saved values.

| Value | What the command accepts |
| --- | --- |
| Domains | Host names only, such as `example.com`: no `https://`, port or path. International names in punycode. |
| Return URLs | Full `https://` addresses with no user name, password or `#` part. Each one's host has to be in the domain list. |

## Make the key for your server

Ask, for example:

```text
Make a Sign in with Apple key called "Notes Web Key" for the app, and tell me where you saved it.
```

The Agent makes it with `asc web sign-in-keys create`, tied to your app's App ID. Apple's [Revoke, edit, and download keys](https://developer.apple.com/help/account/keys/revoke-edit-and-download-keys/) page says a key file can be downloaded only once, and the command downloads it right away, so it runs only with `--confirm` and the Agent asks you first. It saves the file in a folder the Agent names, on the computer it works on, never over another file, and it never prints the key. It reports the key's ID (Key ID), its name and where the file is.

If you already have a key, ask "Which Sign in with Apple keys do we have?" first. `asc web sign-in-keys list` shows each key's ID, its name and whether its file can still be downloaded. It also lists keys for other Apple services.

## Give your server what it needs

Your website's sign-in code needs:

- the Services ID's identifier, from the first step;
- your Apple Team ID, shown under the team in **Settings** › **Developer**;
- the Key ID, and the key file.

Apple's [Sign in with Apple](https://developer.apple.com/documentation/sign_in_with_apple) documentation says how a server uses them. If your Agents write the website in this Project, ask them to set up its sign-in with these.

To use the key on a server you run outside AirBuild, take a copy as below and install it there. Keep the file safe:

- Ask the Agent to save the key file in a folder the project's `.gitignore` leaves out, such as `secrets/`, and to tell you its path. That keeps it out of the repository, a shared link and an export of the source: see [Share or export a project's source](https://air.build/docs/projects/share-and-export-source/#what-the-shared-source-contains). It still shows in **Files**, dimmed, where anyone in the Team can open it.
- To take a copy, open it in **Files** and use **Export** (see [Find the files and documents Agents made](https://air.build/docs/projects/find-files/#save-a-file-or-the-whole-project)), or ask the Agent to send it to you in your DM with that Agent (see [Create group chats and talk to one Agent](https://air.build/docs/projects/groups-and-dms/#talk-to-one-agent)), then touch and hold the file (on the Mac, right-click it) and choose **Save As…**. Don't ask for the key in the Project's chat: everyone in the chat can open it, and you can't recall a message the Agent sent.
- If your website is on Vercel, the Vercel Agent changes environment settings. See [Have an Agent deploy and check your Vercel projects](https://air.build/docs/connect/deploy-to-vercel-with-an-agent/).

## See, change or remove

| Ask | `asc` |
| --- | --- |
| "Which Services IDs do we have?" | `web service-ids list` |
| "Rename the Services ID com.example.notes.web to Notes Website." | `web service-ids rename`, only with `--confirm`, so the Agent asks you first. It keeps what's turned on. |
| "Delete the Services ID com.example.notes.old." | `web service-ids delete`, only with `--confirm`, so the Agent asks you first. |
| "Download the file for Notes Web Key again." | `web sign-in-keys download`, if the list says the file can still be downloaded, and only with `--confirm`, so the Agent asks you first. |
| "Revoke the old Sign in with Apple key." | Agents can't: `asc` doesn't revoke keys. Do it in your Apple Developer account; see Apple's [Revoke, edit, and download keys](https://developer.apple.com/help/account/keys/revoke-edit-and-download-keys/). |

## If something goes wrong

**The Agent says to configure Sign in with Apple and its primary App ID in Developer Portal first.**

The messages are "configure Sign in with Apple and its primary App ID in Developer Portal before setting domains", "sign in with Apple must already be enabled before setting domains" and "services ID must already have a primary App ID configured". Do the step in [Turn on Sign in with Apple for it](https://air.build/docs/build/let-people-sign-in-with-apple-on-your-website/#turn-on-sign-in-with-apple-for-it), then ask again.

**The Agent says the return URL hosts must appear in the domains.**

The message is `--return-url hosts must appear in --domain`. Add the return URL's host to the domain list, or fix the return URL.

**The Agent says a domain or return URL isn't valid.**

The messages are `--domain must contain DNS hostnames, without a scheme, port, or path`, `--domain must contain ASCII DNS hostnames (use punycode for international names)` and `--return-url must contain absolute HTTPS URLs without credentials or fragments`. Give domains as plain host names and return URLs as full `https://` addresses; see the table in [Set the domains and return URLs](https://air.build/docs/build/let-people-sign-in-with-apple-on-your-website/#set-the-domains-and-return-urls).

**The Agent says the update was accepted but couldn't be checked.**

The message says the Developer Portal accepted the Services ID domain update but verification failed. Ask the Agent to look at the Services ID before trying again.

**The Agent says the key exists, but its file wasn't saved.**

The key was made, but the download or the saving failed. Don't ask for a new key. Ask the Agent to check the key list and, if the file can still be downloaded, to download it with `sign-in-keys download`.

**The Agent says Apple denied the request (403).**

The message says the account role likely lacks permission for this action, or the web session expired. Check the owner's role on the Apple team: Apple's [Register a Services ID](https://developer.apple.com/help/account/identifiers/register-a-services-id/) page asks for the Account Holder or Admin role. Have the owner sign in again in **Settings** › **Developer** if asked. See [Connect your Apple Developer account](https://air.build/docs/app-store/connect-apple-developer-account/#sign-in-again).

**The Agent says Apple refused the web session.**

Apple didn't accept the Team owner's Apple sign-in that AirBuild keeps. The Agent tries once more, then asks the owner to sign in again if it still fails. See [Connect your Apple Developer account](https://air.build/docs/app-store/connect-apple-developer-account/#sign-in-again).
