# Add Google sign-in to your app without your own OAuth app

> Add Google sign-in to your app with a single command using shared credentials on thelastapi, skipping Google Cloud console setup entirely.

**You can add Google sign-in to your website immediately by enabling shared OAuth credentials through thelastapi.** Instead of registering a Google Cloud project, creating OAuth consent screens, and copying client secrets into your environment, you run `vibiz auth providers add google` to let your users authenticate right away. Your app receives verified user identities, creates sessions, and stores user records in your project's database without manual provider configuration.

Setting up social authentication normally means opening an external cloud console, filling out brand verification forms, generating client credentials, and wiring callback URLs for every environment. If you just want to test an idea, build a minimum viable product, or ship a working tool for your team, that setup creates unnecessary friction. With thelastapi, Google sign-in is built into the `auth` resource with shared credentials available out of the box.

## How shared Google credentials work

When you enable authentication on a project, thelastapi provisions a sign-in service tied directly to your project's serverless Postgres database. The `auth` resource handles session management, identity verification, and callback routing.

Most identity providers force every developer to register an independent OAuth application before writing a single line of authentication code. thelastapi provides shared OAuth credentials specifically for Google sign-in. When a visitor clicks your sign-in button, they complete Google's authentication flow through the shared service, and the identity tokens return to your project's sign-in endpoints.

Every thelastapi project includes two isolated environments:

- **Development:** Designed for local work on your machine. Its sign-in instance trusts `http://localhost:3000` only and connects to an isolated database branch with your schema and no production rows.
- **Production:** Designed for public visitors. It issues sessions for your verified live domains and persists data to your production database.

Only Google offers shared credentials where you do not need your own OAuth application. If you also want to offer GitHub sign-in, you must supply your own OAuth `client_id` and `client_secret`. And if you ever decide you want your own branding on Google's consent screen down the road, you can switch from shared credentials to your own Google credentials at any time, as covered in [use your own OAuth app for Google sign-in](https://thelastapi.dev/blog/own-oauth-app-google-sign-in).

## Turn on Google sign-in in one command

To start from scratch, initialize a new project with authentication enabled. Adding `auth` automatically includes `database`:

```bash
vibiz init "My SaaS App" --resources auth
```

If you have an existing project folder, add authentication directly:

```bash
vibiz add auth
```

Next, turn on Google sign-in for your local development environment using the CLI:

```bash
vibiz auth providers add google --dev
```

If you are using a full-access key and want to enable it for production at the same time, omit the `--dev` flag:

```bash
vibiz auth providers add google
```

You can also configure this over the HTTP API with a bearer token:

```bash
curl -X PUT "https://thelastapi.dev/v1/projects/prj_123/auth/providers/google?env=development" \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H "content-type: application/json" \
  -d '{"credentials":"shared"}'
```

To inspect your current authentication setup, run:

```bash
vibiz auth --dev
```

The output confirms that Google is enabled with shared credentials and lists the active callback URLs for your environment.

## Wire Google sign-in into your code

When you start your development environment with `vibiz dev`, thelastapi writes your local configuration to `.env.development.local`. This injects four key variables into your application:

| Variable | Purpose |
| --- | --- |
| `VIBIZ_AUTH_BASE_URL` | The sign-in service endpoint for the active environment |
| `VIBIZ_AUTH_COOKIE_SECRET` | Secret used to sign and verify user session cookies |
| `VIBIZ_AUTH_JWKS_URL` | Public keys for verifying JSON Web Tokens independently |
| `VIBIZ_AUTH_PROJECT_ID` | Your unique project identifier |

If you want a complete working starter, initialize your app with the pre-built template:

```bash
vibiz init "My SaaS App" --template nextjs-saas
```

The `nextjs-saas` template wires session routes and helpers automatically. The endpoints under `/api/auth/*` handle OAuth handshakes, while server components check the current visitor:

```ts
import { currentUser } from '@/lib/auth/server';

export default async function DashboardPage() {
  const user = await currentUser();

  if (!user) {
    return (
      <main>
        <p>You must be signed in to view this page.</p>
        <a href="/api/auth/signin/google">Sign in with Google</a>
      </main>
    );
  }

  return (
    <main>
      <h1>Welcome, {user.name}</h1>
      <p>Email: {user.email}</p>
      <a href="/api/auth/signout">Sign out</a>
    </main>
  );
}
```

For custom setups outside Next.js, your backend communicates directly with `VIBIZ_AUTH_BASE_URL` to initiate Google flows and read session payloads. If you want passwordless email alongside Google, you can pair it with [magic link sign-in without building it yourself](https://thelastapi.dev/blog/magic-link-sign-in). For a detailed walkthrough of building full session guards, see [how to add sign-in to a Next.js app](https://thelastapi.dev/blog/add-sign-in-nextjs-app).

## Compare provider options

You can run multiple sign-in methods side by side. Here is how shared Google credentials compare to other authentication methods supported by thelastapi:

| Sign-in method | Shared credentials available? | Requires external setup? | Setup command |
| --- | --- | --- | --- |
| **Google** | Yes | No external app needed | `vibiz auth providers add google` |
| **GitHub** | No | Requires GitHub client id and secret | `vibiz auth providers add github --own --client-id <id>` |
| **Magic link** | Yes (shared sender uses one-time codes) | No external email provider needed | Managed via `vibiz auth` settings |
| **Email + password** | Yes | No external dependencies | Managed via `vibiz auth` settings |

All user records from every provider resolve into the same user identity table inside your project database.

## Test locally and prepare for production

When developing locally, run:

```bash
vibiz dev
```

This creates your development copy, branches your database schema without copying live user records, and starts your sign-in instance. Development sign-in only trusts requests from `http://localhost:3000`. If an incoming OAuth callback points anywhere else in development mode, the request is rejected.

When you are ready to launch, your production environment needs to know where your live site is hosted.

If you host your app using thelastapi hosting, domain registration and sign-in trust happen automatically. If you host your application on another server, your project needs only the authentication service. Follow the guide on how to [use one service](https://thelastapi.dev/docs/use-one) to run sign-in independently.

To authorize an external website to use your production Google sign-in service, add your live domain using the CLI:

```bash
vibiz domains add app.example.com --elsewhere
```

If you run this command with a full-access key, the domain is trusted immediately. If an automated AI agent or a Limited key runs the command, the domain is trusted once you add the requested TXT record (`_vibiz.app.example.com`) and run:

```bash
vibiz domains verify app.example.com
```

Alternatively, the account owner can confirm the domain in the web console. You can also buy a domain directly with `vibiz domains buy example.com` through our [domains](https://thelastapi.dev/docs/domains) service; bought domains are trusted for sign-in immediately without any manual DNS records.

## Configure email domains and access restrictions

If you are building an internal tool or a private business application, you might want to prevent the public from signing in even if they possess a valid Google account.

You can restrict registration to specific email domains. For example, to only allow people with company email addresses to sign in during development:

```bash
vibiz auth domains acme.com,partner.com --dev
```

To remove the restriction and allow anyone with a Google account to sign up:

```bash
vibiz auth domains none --dev
```

You can also update this via the HTTP API:

```bash
curl -X PATCH "https://thelastapi.dev/v1/projects/prj_123/auth/settings?env=development" \
  -H "Authorization: Bearer $VIBIZ_API_KEY" \
  -H "content-type: application/json" \
  -d '{"allowed_email_domains":["acme.com"]}'
```

The sign-in service rejects any Google account whose email domain is not in the allowed list, returning a `400 invalid_request` error during the sign-in attempt. You can read more about controlling environments and managing keys safely in the documentation on [keys and environments](https://thelastapi.dev/docs/keys).

## What to build next

With Google sign-in enabled, your application can authenticate users, protect private pages, and store structured profile data. If your application relies on language models, you can also connect models from OpenAI, Anthropic, and Google with one key, or [use your own Gemini API key or Google Cloud credits through a gateway](https://thelastapi.dev/blog/use-your-own-gemini-key). 

Review the complete reference on the [Sign-in](https://thelastapi.dev/docs/sign-in) documentation page to explore session cookies, token verification, and custom email senders.

## Frequently asked questions

### Do I need a Google Cloud account to use Google sign-in on thelastapi?

No. By running `vibiz auth providers add google`, your project uses thelastapi's shared OAuth credentials, allowing users to sign in without you creating a Google Cloud project or OAuth consent screen.

### Can I restrict Google sign-in to users from my company's domain?

Yes. Run `vibiz auth domains acme.com` to restrict registration to email addresses ending in that domain, with a limit of up to 50 allowed email domains.

### How much does sign-in cost on thelastapi?

There is no separate charge for sign-in today; it is included as part of your project's database service.

### Can I switch from shared credentials to my own Google OAuth client later?

Yes. You can switch to your own OAuth credentials at any time by updating your provider configuration in the console or CLI without changing your database schema or existing user accounts.

---

Published 2026-11-15 · https://thelastapi.dev/blog/add-google-sign-in
