gclientid
gclientid creates a personal Google OAuth application in your own Google Cloud account, with a Web client for scripts and local web apps and a Desktop client for software you distribute. It can also authorize Google accounts and save standard refreshable tokens for Gmail, Drive, Calendar, Contacts, Tasks, Google Cloud, and Workspace administration.
There are two operations:
- Provisioning finds or creates one stable Cloud project per owner and configures its OAuth client in a signed-in Chrome. It reuses or obtains a Cloud-access token for the owner, then batch-enables APIs through Service Usage rather than visiting each API’s Console page. Every run converges on that state, so it is safe to repeat. No existing credentials are needed;
--owneruses existing Cloud credentials for project creation too. Google provides no supported API for a general-purpose OAuth client; its programmatic client API creates IAP-only clients. - Authorization grants a client access to a Google account’s requested data and writes a token. Normally it drives a signed-in Chrome and receives Google’s response on a one-shot local callback; remote sessions can instead use a PKCE-protected appapis copy/paste callback.
gclientid can do both in one command, but provisioning is the default. Everything runs locally and gcloud is neither used nor required.
Install
pip install gclientidQuick start
1. Choose a browser for OAuth setup
Provisioning needs access to a Google Cloud Console session. Choose either approach.
Your normal Chrome: enable Allow remote debugging in chrome://inspect/#remote-debugging, then run gclientid normally. Chrome asks you to approve the connection. This is convenient when your usual browser is already signed into the Cloud account that should own the project.
Dedicated CDP Chrome: install the launcher once:
fastcdp-setupOpen CDP Chrome from the launcher that command creates. On macOS it is in ~/Applications/CDP Chrome.app. In that browser, open https://console.cloud.google.com/ and sign into the account that should own the project. Complete any passkey or other verification prompt. CDP Chrome has a separate profile; being signed into normal Chrome does not sign you into CDP Chrome.
Leave CDP Chrome running, then use:
gclientid --cdp-chromeCDP Chrome does not show a connection-approval prompt. fastcdp-setup creates its launcher; it does not open the browser or sign you in.
2. Create the project and OAuth client
gclientidThis finds or creates your default project through the signed-in Cloud Console, configures branding, scopes, and consent, publishes an External app as an unverified production application, and creates a Web OAuth client. It then authorizes the project owner for Google Cloud access and batch-enables the APIs of the max preset. An existing usable Cloud token is reused without another authorization. No existing token is needed for a first run.
The default project ID is gclientids- plus a hash of the signed-in account’s email, so it is the same on every machine and every run. Reruns reuse the existing project and saved client. They query enabled services and enable only missing APIs. Branding and scopes are read from the Console and saved only when changes are needed.
The Web client is registered with http://127.0.0.1:53682/ for the local callback, https://oauth.appapis.org/redirect for remote authorization, and http://localhost:<port>/redirect and http://127.0.0.1:<port>/redirect for ports 5001, 5002, 8000, and 8080. A local fasthtml app can sign in with the same client. Add more with --redirect; re-running registers any the client lacks.
A Desktop client for software you distribute, which accepts any loopback port and has no redirect list, is one flag away and lives in the same project:
gclientid --desktopGoogle’s API Services terms checkbox is accepted automatically. To pause for manual acceptance instead:
gclientid --no-accept-termsProvisioning writes config.ini, oauth-client.json (or oauth-client-desktop.json), and the owner’s Cloud token when a new authorization is needed. That setup grant requests only identity and Cloud access, not Gmail or Drive data. When Google shows a verification or passkey screen, gclientid prints a message, brings the tab forward, and waits up to ten minutes for you to complete it. Automation resumes after verification.
When an existing gclientid token has cloud-platform access, --owner instead creates and configures the project through Resource Manager and Service Usage:
gclientid --owner me@example.comChrome must also be signed into that account so gclientid can require the same support/contact email. API provisioning grants the owner explicit Service Usage Consumer access. --internal requires this path because the owner token resolves the Workspace organization.
The default External setup prepares an owner token automatically. To add Cloud access to an account with an existing client:
gclientid-auth me@example.com --preset cloudAccess presets
Provisioning declares every scope in the max preset on the project and enables every API it needs. Any later authorization can therefore request any subset without touching the Console again. Presets choose what one authorization requests:
google-apps, the default, requests broad access to Gmail, Drive, Calendar, Contacts, Tasks, Docs, Sheets, and Slides.gmailrequests identity information and unrestricted Gmail access.cloudrequests only identity and Google Cloud access; provisioning uses it for the owner setup grant.colabrequests identity and Google Colab access and enables the Colab API.workspace-addonrequests identity and Google Cloud access and enables the APIs needed to manage Workspace add-on deployments.developercombinesgoogle-appswithcloud-platform. Cloud access remains limited by the authorized account’s IAM roles.workspace-admincombinesgoogle-appswith broad Admin SDK and Enterprise License Manager access. Admin operations remain limited by the account’s Workspace privileges.maxcombinesgoogle-apps,developer,workspace-admin, andcolab. It is every scope and API in gclientid’s built-in presets, not every API Google offers.
Choose the default while provisioning, or override it for one authorization:
gclientid --preset max
gclientid-auth me@example.com --preset gmailScopes and APIs beyond max are declared and enabled on the project while provisioning, and every later authorization requests them:
gclientid --scope https://www.googleapis.com/auth/forms.body --api forms.googleapis.comRepeat --scope and --api as needed. gclientid-auth --scope adds a scope to one authorization.
Internal Workspace applications
Use --internal when every user belongs to the Cloud project’s Google Workspace or Cloud Identity organization:
gclientid --owner me@example.com --internal --preset workspace-addon
gclientid-auth me@example.com --internalThe owner email’s domain is resolved to its Cloud organization through Resource Manager, and the project is created under it. Internal credentials are kept alongside, rather than replacing, the default External profile: config-internal.ini, oauth-client-internal.json, and oauth-token-<account>-internal.json.
Stored files
Credentials and settings live directly under $XDG_CONFIG_HOME/gclientid/, normally ~/.config/gclientid/:
config.ini
oauth-client.json
oauth-client-desktop.json
oauth-token-alice@example.com.json
oauth-token-alice@example.com-desktop.json
oauth-token-bob@example.com.json
config-internal.ini
oauth-client-internal.json
oauth-token-alice@example.com-internal.json
config.ini records the project, application name, default preset, custom scopes/APIs, the browser you use, and whether tokens re-authorize automatically. oauth-client.json holds Google’s Web client and oauth-client-desktop.json the Desktop client, in the web and installed shapes Google’s own downloads use. Each verified account gets one oauth-token-<account>.json per client in google-auth’s authorized-user format. Credential JSON files are written with mode 0600.
gclientid also loads, refreshes, and revokes these tokens, and fastgws re-exports the same functions from fastgws.auth. A refresh failure names the gclientid-auth command that recreates the grant:
from gclientid import oauth_creds
creds = await oauth_creds(account='alice@example.com')
desktop = await oauth_creds(account='alice@example.com', desktop=True)Pass --output to either command to use another credential directory. Provisioning converges on the requested state and never replaces an existing client; successful authorization replaces only the selected account’s token.
Personal, unverified applications
The intended setup is one Cloud project and OAuth client per developer or small team. gclientid configures an External, In production, unverified application. Google warns that sensitive or restricted scopes require verification, but an unverified personal-use application can still authorize up to 100 distinct users over its lifetime. Verification is needed to remove the warning or exceed that cap.
Do not leave a Gmail application in Testing: test users need an allowlist, and grants involving Gmail expire after seven days. An unverified production application avoids both limitations.
Google may still require a passkey or Touch ID for a broad grant even when the account is already signed in. Those are browser-native security decisions; complete them in the browser. An immediate repeat often reuses Google’s recent authentication and does not prompt again.
Python API
provision and authorize_account are the two commands as functions, with the same options:
from gclientid import authorize_account, provision
await provision(desktop=True, cdp_chrome=True)
token_path = await authorize_account('me@example.com', desktop=True, cdp_chrome=True)Each Console step is its own function taking a signed-in page: console_account, ensure_project_ui, configure_app, create_client, and add_redirects. For finer control, call setup_auth, set_branding, set_scopes, and publish_app separately instead of configure_app. set_branding returns whether it changed anything. set_scopes adds missing scopes and returns the added list. publish_app is for External apps. See AGENTS.md for the semi-interactive workflow and credential-file handoff.
enable_apis uses Service Usage with Cloud credentials. provision_project handles both the project and API steps through REST:
from gclientid import add_redirects, configure_app, connect_browser, create_client, provision_project
project_id = 'gclientids-your-unique-suffix'
await provision_project('me@example.com', project_id, name='gclientids', domain='example.com',
apis=['cloudresourcemanager.googleapis.com', 'gsuiteaddons.googleapis.com'])
cdp, page = await connect_browser()
await configure_app(page, project_id, internal=True, support_email='me@example.com')
await create_client(page, project_id, 'oauth-client-internal.json')
await add_redirects(page, 'oauth-client-internal.json', ['http://localhost:3000/redirect'])connect_browser() targets normal Chrome and gives the user up to 60 seconds to approve the debugging connection. Use the dedicated profile with connect_browser(default_browser=False).
Authorization can reuse an existing CDP connection; without one it opens the system’s default browser and still receives the local callback automatically:
from gclientid import authorize_google
token = await authorize_google(
'oauth-client.json',
'oauth-token.json',
preset='google-apps',
account='me@example.com')Pass cdp=cdp to open the flow in a particular CDP browser, or remote=True to print the appapis URL and read its copied result. Both paths verify the account and write the same standard authorized-user token.
Project deletion is also available. Google treats this as a recoverable shutdown for 30 days:
from gclientid import delete_project
await delete_project('me@example.com', project_id)See DEV.md for the API and remaining Cloud Console implementation details, and PRIVACY.md for the privacy policy.
Development
pip install -e .[dev]Version lives in gclientid/__init__.py. Releases use:
ship-release