Creating a Google OAuth 2.0 client
This guide is part of the Publicus connection catalog. Once you have the credentials, connect the service and Publicus stores them for you.
Distilled from Google’s own documentation: Using OAuth 2.0 for Web Server Applications and Setting up OAuth 2.0. Retrieved 2026-07-03.
- Open the Google Auth Platform Branding page (Google Cloud console → Menu → Google Auth platform → Branding) and configure the OAuth consent screen: app name, user support email, user type (Internal/External), and contact email.
- For External apps still in Testing publishing status, add test users under Audience → Test users. Note: refresh tokens issued while in Testing expire after 7 days (unless only name/email/profile scopes are requested).
- Under Data Access, click Add or Remove Scopes and select the minimum scopes the app needs (see the per-service capability scopes in this catalog entry).
- Enable each target API in the API Library (e.g. Gmail API, Google Drive API, Google Sheets API, Google Calendar API) — click the API, then Enable.
- Go to the Clients page (Google Auth platform → Clients), click Create Client, and choose application type Web application.
- Under Authorized redirect URIs, click Add URI and enter the callback URL exactly as shown on the connect form — redirect URIs are exact-match; any mismatch produces
redirect_uri_mismatch. - Click Create and record the client ID and client secret (also downloadable as
client_secret.json). Copy the secret now. Google hashes client secrets and shows the full value only at creation — if you lose it there is no way to read it back, only to add a new secret and rotate (Google Auth platform updates).
APIs that ask for more than a client
Section titled “APIs that ask for more than a client”Most Google APIs work as soon as the API is enabled (step 4) and the person has consented. Two need more. From Register as a developer and Authorizing requests to Merchant API for the Merchant API, and Set up API access for the Data Manager API. Retrieved 2026-11-20.
Merchant API (Merchant Center)
Section titled “Merchant API (Merchant Center)”Google blocks every Merchant API call from a Google Cloud project that is not registered as a developer. An unregistered project gets 401 UNAUTHENTICATED with the message GCP project … is not registered with the merchant account.
-
In the API Library, enable the Merchant API in the project that owns the client, and add the scope
https://www.googleapis.com/auth/contentunder Data Access. -
Check the Merchant Center account you will register. It must be a production account with a verified website, and the person who connects must have Admin access to it. Test accounts cannot be registered.
-
Connect with that person’s Google Account, then call the registration method once. It is the one Merchant API call an unregistered project may make:
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/developerRegistration:registerGcp{"developerEmail": "developer@example.com"}ACCOUNT_IDis the Merchant Center ID.developerEmailis the technical contact Google writes to about the API, and it may not be a service account. In this catalog the method is in themerchantapi-accountsservice. -
Wait up to 5 minutes before the next call. If the email was not yet a user of the account, that person receives an invitation and must accept it within 14 days, or the registration has to be done again.
-
Keep at least one user with the API developer role on the account. Google blocks the project’s calls 30 days after the last one is removed.
A project can be registered with one Merchant Center account at a time: a second registration answers ALREADY_REGISTERED. One registration covers that account and its sub-accounts. If you manage several merchants as an agency or developer, register the account that represents your own business, not each merchant’s.
Data Manager API
Section titled “Data Manager API”- In the API Library, enable the Data Manager API, and add the scope
https://www.googleapis.com/auth/datamanagerunder Data Access. Addhttps://www.googleapis.com/auth/datamanager.partnerlinkonly if you are a data partner that creates partner links. - Google treats both scopes as sensitive. While the app’s publishing status is Testing, only the test users you list can connect. Before other people connect, the app has to pass Google’s OAuth app verification, unless it is internal to your Google Workspace organisation.
- Give the person who connects access to the destination their data goes to: add their email as a user of the Google Ads account (or a manager account above it), the Display & Video 360 account or the Google Analytics account.
Operational notes (from developers.google.com/identity/protocols/oauth2):
- Request
access_type=offlineand be ready forprompt=consentre-consent — Google only returns a refresh token on the first code exchange. - Google caps refresh tokens at 100 per account per client; the oldest is silently invalidated past the cap.
- A client left unused is deleted. Google removes OAuth clients with no activity for six months. A client created for a workspace that then sits idle — a seasonal integration, a staging tenant — can be gone when you come back to it, and the failure looks like a revoked grant rather than a missing client (Google Auth platform updates).
- Restricted scopes cost more than consent. Gmail’s read scopes (
gmail.readonly,gmail.modify,mail.google.com) are restricted, which pulls any app that reaches that data from a server into an annual third-party security assessment.gmail.sendis only sensitive and does not. If sending is all you need, ask only for that — see this entry’sclient_expectation.
Connect it to Publicus
Section titled “Connect it to Publicus”Open Connections under Credentials, choose Google, and pick Google OAuth 2.0. Publicus asks for exactly the fields listed above and keeps them in your workspace’s secret storage.
See also: Google in the catalog.
This guide is maintained by Publicus and published under CC BY 4.0.