---
title: "Set up sign-in and payments"
description: "Create the Google, GitHub, and Polar credentials your project needs, and put each half in the right place."
canonical_url: "https://nuxtstart.com/docs/configuration/provider-accounts"
---

> Index of every page on this site: [llms.txt](https://nuxtstart.com/llms.txt)

`apps/web` signs users in with Google and GitHub, and charges them through
[Polar](https://polar.sh). Each provider gives you two things: a public identifier that goes into
Git, and a secret that goes into your secret store.

Every key below is required, so `apps/web` doesn't start until each one holds a value. If you aren't
using a provider yet, put a stand-in such as `unused` in its keys and come back later. The product
starts and deploys, and only that provider's feature fails when you first use it.

## Where each value goes

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Needed for
    </th>
    
    <th>
      Goes in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        GOOGLE_CLIENT_ID
      </code>
    </td>
    
    <td>
      Google sign-in (<code>
        @app/layer-auth
      </code>
      
      )
    </td>
    
    <td>
      <code>
        apps/web/.env.<context>
      </code>
      
      , in Git
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GOOGLE_CLIENT_SECRET
      </code>
    </td>
    
    <td>
      Google sign-in (<code>
        @app/layer-auth
      </code>
      
      )
    </td>
    
    <td>
      Your secret store
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GITHUB_CLIENT_ID
      </code>
    </td>
    
    <td>
      GitHub sign-in (<code>
        @app/layer-auth
      </code>
      
      )
    </td>
    
    <td>
      <code>
        apps/web/.env.<context>
      </code>
      
      , in Git
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GITHUB_CLIENT_SECRET
      </code>
    </td>
    
    <td>
      GitHub sign-in (<code>
        @app/layer-auth
      </code>
      
      )
    </td>
    
    <td>
      Your secret store
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        POLAR_ACCESS_TOKEN
      </code>
    </td>
    
    <td>
      Payments (<code>
        @app/layer-payments
      </code>
      
      )
    </td>
    
    <td>
      Your secret store
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        POLAR_WEBHOOK_SECRET
      </code>
    </td>
    
    <td>
      Payments (<code>
        @app/layer-payments
      </code>
      
      )
    </td>
    
    <td>
      Your secret store
    </td>
  </tr>
</tbody>
</table>

`POLAR_SERVER` picks the Polar environment. It's already set in every value file, so it needs
nothing from you until you go live.

[Set up your secret store](https://nuxtstart.com/docs/configuration/secret-store) covers which folder the secrets go in.
[Environment values](https://nuxtstart.com/docs/reference/environment-values#why-some-credentials-are-committed) explains
why the client IDs are committed instead.

## Register these callback URLs

Create a separate OAuth application for each context you deploy, and a separate
[Polar organization](#create-one-organization-per-context) for each context. Each one has a different
origin, and a callback URL is registered per exact URL.

For local development, the origin is `http://web.<slug>.localhost` in the main checkout, and
`http://<worktree label>.web.<slug>.localhost` in a worktree. For a deployed context, it's the
`NUXT_PUBLIC_APP_BASE_URL` you wrote into that context's `apps/web/.env.<context>` —
[Project identity](https://nuxtstart.com/docs/reference/project-identity#serving-origins) explains the shape each one
takes. A product mounted under the site puts its mount, the `NUXT_APP_BASE_URL` it deploys with,
before `/api`, so `example.com/app/` registers `https://example.com/app/api/auth/callback/google`.
[Attaching a domain](https://nuxtstart.com/docs/deployment/pipeline#attaching-a-domain) covers the mount.

<note>

A pull request preview gets a different origin per pull request, so no callback URL can be registered
for it in advance. Social sign-in fails on a preview, and that's expected.

</note>

<table>
<thead>
  <tr>
    <th>
      Provider
    </th>
    
    <th>
      Callback URL
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Google
    </td>
    
    <td>
      <code>
        <origin>/api/auth/callback/google
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      GitHub
    </td>
    
    <td>
      <code>
        <origin>/api/auth/callback/github
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Polar
    </td>
    
    <td>
      <code>
        <origin>/api/webhooks/polar
      </code>
      
       (webhook endpoint)
    </td>
  </tr>
</tbody>
</table>

## Google

Create an OAuth 2.0 client ID of type **Web application** in the Google Cloud console, under
**APIs & Services** > **Credentials**. Add `<origin>/api/auth/callback/google` as an authorized
redirect URI for each deployed context.

Google sign-in doesn't work locally. Google refuses every `*.localhost` redirect URI, so test it on
`development` instead.

Google's [OAuth 2.0 setup guide](https://developers.google.com/identity/protocols/oauth2) covers the
consent screen and publishing.

The console gives you a client ID and a client secret. Put the ID in `apps/web/.env.development` and
the secret in your secret store.

## GitHub

Create an OAuth app under **Settings** > **Developer settings** > **OAuth Apps**, and set the
authorization callback URL to `http://web.<slug>.localhost/api/auth/callback/github`. Tick
**Allow wildcard matching**, so the one callback also covers every worktree's subdomain. See
GitHub's guide to [creating an OAuth app](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app).

GitHub shows the client ID immediately and generates the client secret on request. The secret is
shown once.

## Polar

Use the [Polar sandbox](https://sandbox.polar.sh) for everything except production. A token issued
by one Polar environment doesn't work against the other, and the mismatch surfaces at the first API
call rather than at startup — so check which dashboard you're in before copying a token.

### Create one organization per context

Give each Runtime Context its own organization, `local` included. In a shared organization, sign-up
refuses an email another context already used, and each context's webhook receives the other's
purchases.

<table>
<thead>
  <tr>
    <th>
      Runtime Context
    </th>
    
    <th>
      Dashboard
    </th>
    
    <th>
      Name and slug
    </th>
    
    <th>
      Webhook
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        local
      </code>
    </td>
    
    <td>
      <a href="https://sandbox.polar.sh" rel="nofollow">
        sandbox
      </a>
    </td>
    
    <td>
      <code>
        <slug>-web-local
      </code>
    </td>
    
    <td>
      Your Funnel URL — see <a href="#receive-webhooks-locally">
        Receive webhooks locally
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        development
      </code>
    </td>
    
    <td>
      sandbox
    </td>
    
    <td>
      <code>
        <slug>-web-development
      </code>
    </td>
    
    <td>
      <code>
        <origin>/api/webhooks/polar
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        preview
      </code>
    </td>
    
    <td>
      sandbox
    </td>
    
    <td>
      <code>
        <slug>-web-preview
      </code>
    </td>
    
    <td>
      None — put a stand-in in its <code>
        POLAR_WEBHOOK_SECRET
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        staging
      </code>
    </td>
    
    <td>
      sandbox
    </td>
    
    <td>
      <code>
        <slug>-web-staging
      </code>
    </td>
    
    <td>
      <code>
        <origin>/api/webhooks/polar
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        production
      </code>
    </td>
    
    <td>
      <a href="https://polar.sh" rel="nofollow">
        polar.sh
      </a>
    </td>
    
    <td>
      <code>
        PROJECT_DISPLAY_NAME
      </code>
      
      , <code>
        PROJECT_SLUG
      </code>
    </td>
    
    <td>
      <code>
        <origin>/api/webhooks/polar
      </code>
    </td>
  </tr>
</tbody>
</table>

`<slug>` is your `PROJECT_SLUG`. Create each organization when you add its context. Production's takes
your display name because Polar's emails to your customers carry it.

To create an organization:

1. Sign in to the dashboard the table names. The sandbox keeps its own accounts, so sign up there the
first time.
2. Select the current organization's name at the bottom of the sidebar, then select
**New Organization**. A new account starts on this form.
3. Enter the name and the slug from the table.

`preview` has no webhook because each pull request serves from its own origin. Every pull request
shares preview's organization but starts with an empty database, so sign-up refuses an email an
earlier pull request used. Sign up with a new address on each one, such as `you+pr12@example.com`.

### Copy the organization's credentials

Take both credentials from the organization the table names for the context. They come from two
different pages:

1. **POLAR_ACCESS_TOKEN** — create an organization access token under **Settings** >
**Developer**. See [Polar authentication](https://docs.polar.sh/api-reference/authentication).
2. **POLAR_WEBHOOK_SECRET** — add a webhook pointing at `<origin>/api/webhooks/polar`,
then copy the signing secret from that webhook's own settings page. It isn't the access token,
and the developer settings page doesn't show it. Set the webhook's API version to the one in the
`@polar-sh/sdk/<version>` import of `packages/layer-payments/server/api/webhooks/polar.post.ts`.
The handlers expect that version's payload shape.

Requests whose signature doesn't verify against the webhook secret are rejected, so a wrong value
looks like Polar events silently never arriving.

### Receive webhooks locally

Polar can't reach `http://web.<slug>.localhost`, so the `local` webhook arrives through
[Tailscale Funnel](https://tailscale.com/kb/1223/funnel). Funnel makes `apps/web` public at your
machine's fixed `https://<machine>.<tailnet>.ts.net`, so you register the endpoint once. Purchases
still sync without it, but Polar can't deliver while Funnel is off. It drops each event after 10
failed attempts, and disables the endpoint after 10 failed events in a row. Before a run with Funnel
on, re-enable the endpoint in Polar's webhook settings if Polar disabled it, and redeliver the
events you need.

1. Set up Tailscale once, as [Receive Polar webhooks locally](https://nuxtstart.com/docs/getting-started/local-setup#optional-receive-polar-webhooks-locally)
describes.
2. Start the app with Funnel on for this run:```bash [Terminal]
PORTLESS_FUNNEL=1 pnpm dev:web
```
3. In the `<slug>-web-local` organization, point the webhook at
`https://<machine>.<tailnet>.ts.net/api/webhooks/polar`. portless prints the URL when it starts.

Funnel stays off unless you set `PORTLESS_FUNNEL=1`, and `pnpm dev:site` is never made public. No
other tunnel is supported: the dev command switches portless's other tunnels off.

Only one checkout receives webhooks at a time. The endpoint names Funnel's port 443, and a server on
another port would receive nothing. So the dev command stops when another server already holds 443.
Stop that server's Funnel first. Webhooks that reach the wrong checkout fail against its database,
and Polar disables an endpoint whose deliveries keep failing.

## Next steps

- [Set up your secret store](/docs/configuration/secret-store) — where the secret half of each pair
goes
- [Local setup](/docs/getting-started/local-setup) — the rest of getting the project running

## Sitemap

See the full [sitemap](https://nuxtstart.com/sitemap.md) for all pages.
