Use your own OAuth app for Google sign-in
Use your own Google OAuth client ID and secret in thelastapi to show your company's name and branding on the Google sign-in consent screen.
On this page 8 sections
- Shared keys versus your own Google OAuth app
- Where to find your callback URL
- How to create your Google OAuth client ID and secret
- How to add your Google credentials to the project
- How environments and keys handle OAuth secrets
- What to do if your app runs on a custom domain
- Wiring sign-in in your frontend application
- FAQ
To use your own OAuth app for Google sign-in, get your environment's callback URL from vibiz auth, create a web client ID in Google Cloud, and run vibiz auth providers add google --own --client-id <id>. Your own credentials display your business name, domain, and logo on Google's consent screen instead of shared platform defaults. You can configure your credentials independently for production and development, protecting your production users while testing locally.
If you want to start without setting up a Google Cloud project, you can add Google sign-in without your own OAuth app using shared keys. When you want full control over your branding and verification, switch to your own client credentials by following this guide.
Shared keys versus your own Google OAuth app
Every thelastapi project with the auth resource supports Google sign-in out of the box. You have two ways to configure it:
| Feature | Shared credentials | Your own Google OAuth app |
|---|---|---|
| Setup step | Run vibiz auth providers add google | Create credentials in Google Cloud, then supply ID and secret |
| Consent screen brand | thelastapi default | Your business name, logo, and terms links |
| Who can configure in production | Full-access key or console owner | Full-access key or console owner |
| Agent configuration in development | Yes (vibiz_auth_settings) | No (secrets require human input via prompt or console) |
| Environment separation | Works immediately in both environments | Recommended: separate Google client IDs for dev and prod |
Shared keys are ideal for prototypes and internal tools. For customer-facing SaaS products, using your own Google client ID ensures your users see your own brand name when authorizing access.
Where to find your callback URL
Before configuring credentials in Google Cloud, you need the authorized redirect URI that Google sends tokens back to.
To view your project's sign-in settings and callback URLs, run:
vibiz auth --jsonFor your local development environment, pass the --dev flag:
vibiz auth --dev --jsonThe output contains the callback_url for Google in that environment. It also includes an available_providers object that lists the steps and destination URLs for provider consoles.
Production and development environments each maintain their own sign-in service and callback URLs. The development environment trusts http://localhost:3000 only, while production trusts the custom domains assigned to your project.
How to create your Google OAuth client ID and secret
To generate your credentials:
- Go to the Google Cloud console and select or create your Google Cloud project.
- Navigate to APIs & Services > OAuth consent screen.
- Choose External (or Internal if restricted to Google Workspace users in your organization) and click Create.
- Enter your app name, user support email, and developer contact email. Save and continue through the Scopes screen (the base sign-in flow uses standard openid, profile, and email scopes).
- Navigate to APIs & Services > Credentials.
- Click Create Credentials at the top and select OAuth client ID.
- Set the application type to Web application.
- In the Authorized redirect URIs section, add the exact
callback_urlobtained fromvibiz auth. - Click Create. Google displays your Client ID and Client secret.
Keep this window open or save the secret securely. If you run multiple AI tools on Google Cloud, you can also use your own Gemini API key or Google Cloud credits alongside your sign-in configuration.
How to add your Google credentials to the project
Once you have your Google client ID and client secret, add them to your project using the CLI or the console.
To configure your production environment:
vibiz auth providers add google --own --client-id 1234567890-abcdef.apps.googleusercontent.comThe CLI prompts you for the client secret with hidden input, preventing secrets from leaking into your shell history:
Enter Google client secret: ********Alternatively, you can provide the secret via the environment variable GOOGLE_CLIENT_SECRET:
GOOGLE_CLIENT_SECRET=GOCSPX-yourSecretKey vibiz auth providers add google --own --client-id 1234567890-abcdef.apps.googleusercontent.comTo configure your local development environment with separate test credentials, add the --dev flag:
vibiz auth providers add google --own --client-id 1234567890-devid.apps.googleusercontent.com --devIf you manage your project over plain HTTP, update settings using the project's API:
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": "own",
"client_id": "1234567890-devid.apps.googleusercontent.com",
"client_secret": "GOCSPX-devSecret"
}'When you inspect settings later with vibiz auth, client secrets are never returned. The API returns has_client_secret: true instead.
To remove your custom Google provider settings at any point, run:
vibiz auth providers rm googleHow environments and keys handle OAuth secrets
thelastapi strictly divides production access from automated developer tooling. Under the permissions model detailed in Keys and environments, API keys have two default access levels: Full access (access: owner) and Limited (access: agent).
- Full-access keys can configure production sign-in settings, connect live domains, and read environment values.
- Limited keys are restricted to the development environment. They can start local development branches, modify dev settings, and toggle shared-key providers.
- Secrets require a human. Neither production OAuth secrets nor SMTP passwords can be passed through AI agent prompts. If a Limited key attempts to update production sign-in settings, the API answers
403 forbiddenwithdetails.reason: "owner_only"and provides adetails.console_urlwhere the account owner can finish the configuration.
If you collaborate with other developers or work with other identity providers, you can also add GitHub sign-in to your app using a similar --own configuration.
What to do if your app runs on a custom domain
When you deploy your application to production, Google sign-in works in concert with your verified domains.
If you host your frontend on thelastapi hosting or purchase a domain using vibiz domains buy, your domain is automatically verified and trusted by the sign-in service:
vibiz domains buy acme.com
vibiz domains use acme.com --project prj_123As covered in the Domains documentation, bought domains have their DNS managed automatically. Sign-in and analytics accept visits from the apex domain and www immediately.
If your frontend is hosted outside thelastapi, you can use one service independently. Register your custom domain so the sign-in service accepts it:
vibiz domains add app.example.com --elsewhereWhen added with a Limited key, sign-in trusts the external domain once you add the generated TXT record (_vibiz.app.example.com) and run:
vibiz domains verify app.example.comAn account owner can also confirm the domain directly in the console.
Wiring sign-in in your frontend application
Once Google sign-in is enabled, your application reads the environment configuration through the @vibiz/app package or standard environment variables.
If you generated your project using the SaaS template (vibiz init myapp --template nextjs-saas), user sessions and sign-in routes are already wired under /api/auth/*. To learn how to structure your session validation and protected pages, read how to add sign-in to a Next.js app.
For projects running on any server or container, load the environment variables at startup:
import { vibiz } from '@vibiz/app';
// Injects VIBIZ_AUTH_BASE_URL, VIBIZ_AUTH_COOKIE_SECRET, and DATABASE_URL
await vibiz.loadEnv();Your server code can now read process.env.VIBIZ_AUTH_BASE_URL to route incoming OAuth flows, while the session cookie is encrypted using process.env.VIBIZ_AUTH_COOKIE_SECRET.
To explore all supported authentication methods, callback parameters, and session limits, see the official Sign-in documentation. You can also run vibiz dev to test your Google sign-in flow locally against an isolated database branch.
Frequently asked questions
Can I use shared Google keys in development and my own OAuth app in production?
Yes. You can keep shared keys in development by running `vibiz auth providers add google --dev` while applying your custom credentials to production with `vibiz auth providers add google --own --client-id <id>`.
Where do I find the authorized redirect URI to add into Google Cloud?
Run `vibiz auth --json` (or `vibiz auth --dev --json` for local testing). The returned settings object includes the exact `callback_url` property you must paste into the Google Cloud credentials screen.
Can an AI agent configure my production Google client secret?
No. AI agents using Limited keys receive a `403 owner_only` error when attempting to update production authentication settings; custom OAuth secrets must be entered by an account owner via the web console or interactive CLI prompt.
How do I verify my custom domain so Google sign-in works outside thelastapi hosting?
Add the domain using `vibiz domains add app.example.com --elsewhere`, place the specified TXT verification record in your DNS provider, and run `vibiz domains verify app.example.com` (or have the account owner confirm it in the console).