> ## Documentation Index
> Fetch the complete documentation index at: https://www.anything.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Third-party mobile auth

> Let people sign in to your mobile app with Google or Apple

Let people sign in to your iOS or Android app with their Google or Apple account. Both work through the same sign-in pages your app already has, so once a provider is set up the button shows up on mobile and web together.

This page covers Google and Apple on mobile. For the email and password basics, protected pages, and how sessions work, see [User Accounts](/docs/apps/auth).

<Info>
  Sign in with Apple is required by Apple's App Store guidelines if your iOS app offers any other social login (like Google). If you add Google to a mobile app, add Apple too, or your build can be rejected during App Store review.
</Info>

## How it works on mobile

Your mobile app opens a sign-in screen that loads your app's hosted sign-in page. The Google and Apple buttons live on that page, so the flow is the same one your web app uses. You don't wire up any native SDKs or device-specific code. Set the provider up once and Anything renders the button everywhere.

When you test inside the builder, the sign-in page shows up as a web page inside a preview. That's expected. It works as a normal native screen once the app is running on a real device.

## Before you start

<Check>
  An Anything project with [User Accounts](/docs/apps/auth) turned on
</Check>

<Check>
  Your app published, or running on a preview domain you can test against
</Check>

<Check>
  A developer account with the provider: a Google account for Google, an [Apple Developer account](/docs/apps/mobile/verify-apple-developer-account) for Apple
</Check>

## Sign in with Google

You create OAuth credentials in Google, then paste them into your project. The setup is the same as web, so follow the full walkthrough and the mobile button comes along automatically.

<Steps>
  <Step title="Create Google credentials">
    Follow the [Google Sign In guide](/docs/auth/google) to create a project in Google Cloud, set up the OAuth consent screen, and generate a Client ID and Client Secret.
  </Step>

  <Step title="Add the redirect URL">
    In your Google OAuth client, add this as an authorized redirect URL, replacing the host with your app's domain (your published domain in production, or your preview domain to test in the builder):

    ```
    https://<your-app-domain>/api/auth/callback/google
    ```
  </Step>

  <Step title="Enable Google in Project Settings">
    Open the [3-dot menu](/docs/builder/controls) > Project Settings > Authentication, expand Google, turn it on, and paste in your Client ID and Client Secret. Save.
  </Step>

  <Step title="Add the button">
    Back in chat, say "add Google sign in as an option." Anything updates your sign-in and sign-up pages with the Google button. It shows up on both mobile and web.
  </Step>

  <Step title="Publish and test">
    Publish, open your app, and run through the Google flow. Check the [`auth_users` table](/docs/apps/databases) to confirm the account was created.
  </Step>
</Steps>

## Sign in with Apple

Apple uses four pieces of credential instead of a single client ID and secret. You generate them in your Apple Developer account.

<Steps>
  <Step title="Create a Services ID">
    In the [Apple Developer portal](https://developer.apple.com/account/resources/identifiers/list/serviceId), create a Services ID. This is your Apple **Client ID**. Enable "Sign in with Apple" on it.
  </Step>

  <Step title="Add the redirect URL">
    While configuring the Services ID, add this as a Return URL, replacing the host with your app's domain (your published domain in production, or your preview domain to test in the builder):

    ```
    https://<your-app-domain>/api/auth/callback/apple
    ```

    <Warning>
      Apple requires `https` and a reachable domain. You can't use a local address, and the domain has to match the one your app is served from.
    </Warning>
  </Step>

  <Step title="Create a sign-in key">
    Under Keys, create a new key with "Sign in with Apple" enabled. Download the `.p8` private key file. You only get to download it once, so keep it safe. Note the **Key ID** shown next to it.
  </Step>

  <Step title="Find your Team ID">
    Your **Team ID** is in the top right of the Apple Developer portal, under your account membership details.
  </Step>

  <Step title="Enable Apple in Project Settings">
    Open the [3-dot menu](/docs/builder/controls) > Project Settings > Authentication, expand Apple, turn it on, and fill in:

    | Field       | Where it comes from                           |
    | ----------- | --------------------------------------------- |
    | Client ID   | Your Services ID identifier                   |
    | Team ID     | Your Apple Developer Team ID                  |
    | Key ID      | The ID of the key you created                 |
    | Private Key | The contents of the `.p8` file you downloaded |

    Save.
  </Step>

  <Step title="Add the button">
    Back in chat, say "add Sign in with Apple as an option." Anything updates your sign-in and sign-up pages with the Apple button on mobile and web.
  </Step>

  <Step title="Publish and test">
    Publish, open your app, and run through the Apple flow. Check the [`auth_users` table](/docs/apps/databases) to confirm the account was created.
  </Step>
</Steps>

<Note>
  Apple only sends a person's name on their first sign-in, and they can choose to hide their real email behind a private relay address. Don't assume you'll get a name or a reachable email on every sign-in. Collect anything else you need in an onboarding step after the account is created.
</Note>

## Testing

1. Publish your changes, or use your preview domain
2. Open your app on a device or in Expo Go
3. Tap the Google or Apple button on the sign-in screen and finish the flow
4. Check the [`auth_users` table](/docs/apps/databases) to see the new user

## Troubleshooting

<AccordionGroup>
  <Accordion title="The button doesn't show up">
    * Confirm [User Accounts](/docs/apps/auth) is on
    * Confirm the provider is enabled in Project Settings > Authentication
    * Re-publish, then reload the app
  </Accordion>

  <Accordion title="Sign-in shows up as a web page in the builder">
    That's expected. Sign-in renders as a web page inside the builder preview and works as a normal screen once the app runs on a device.
  </Accordion>

  <Accordion title="Redirect or callback error">
    * Check the redirect URL exactly matches `https://<your-app-domain>/api/auth/callback/google` or `.../apple`
    * Make sure the host is your real app domain, not a local address
    * For Apple, confirm the Return URL on the Services ID matches
  </Accordion>

  <Accordion title="Apple rejected the build">
    If your iOS app has Google (or any other social login) but not Apple, App Store review can reject it. Add Sign in with Apple and re-submit.
  </Accordion>
</AccordionGroup>

## See also

<CardGroup cols={2}>
  <Card title="User Accounts" icon="user" href="/docs/apps/auth">
    Email, sessions, protected pages
  </Card>

  <Card title="Google Sign In" icon="google" href="/docs/auth/google">
    Full Google credential setup
  </Card>

  <Card title="Verify Apple developer account" icon="apple" href="/docs/apps/mobile/verify-apple-developer-account">
    Get your Apple account ready
  </Card>

  <Card title="Mobile" icon="mobile" href="/docs/apps/mobile">
    Build and publish mobile apps
  </Card>
</CardGroup>
