Wiring the Google Ads API OAuth Flow for an AI Assistant Through an MCP Server
Set up the four credential layers once, and no browser prompts follow.

Google Ads MCP connects an AI assistant to Google Ads through tools for reporting and limited changes. Wiring its OAuth flow means matching the Cloud project’s access level, OAuth client, and stored credentials to the server’s transport. Get those layers right, and the assistant can work on the user’s behalf without repeated browser sign-ins.
What the Google Ads MCP server actually does and what it cannot do
Google’s MCP developer guide shows how an AI agent connects to the Google Ads API. A prompt leads the model to pick a tool, the server queries the API, and structured results return to the model’s context window. The assistant then answers in plain language. The server handles the API interaction rather than asking the model to manage credentials itself.
Its tool surface is deliberately narrower than the API. The official server can do reads and partial mutations, which include asset creation, video uploads, and label management with propose-and-confirm validation. It can also run read-only. The full API is needed for campaign creation, bid adjustment, and pausing. That boundary separates an assistant that analyzes accounts and makes supported changes from one that manages campaigns end to end.
Transport determines how that bridge authenticates its calls. Local runs use standard input/output, or stdio, with Application Default Credentials, usually shortened to ADC. Remote Cloud Run deployments use Streamable HTTP with OAuth 2.0 Web application credentials. Both paths may lead to the same account data, but each uses credentials in a different way.
What the credential stack looks like before any code runs
The connection depends on four objects working together. A Google Cloud project has the Google Ads API enabled, and that project has an API access level. An OAuth client ID and client secret belong to the project. A refresh token minted through user consent then lets the server obtain access tokens without repeatedly opening a browser. For eligible Workspace-domain deployments, a service account key file provides an alternative credential path.
The project anchors the whole chain of trust. It determines both the OAuth client’s home and the API access level, which is Test, Explorer, Basic, or Standard. User consent does not replace project approval. A project without production approval can fail with AuthorizationError.CLOUD_PROJECT_NOT_APPROVED_FOR_PRODUCTION even when the user has completed OAuth.
For an MCC account, set GOOGLE_ADS_LOGIN_CUSTOMER_ID without hyphens or pass the login customer ID per tool call. This identifies the manager account context.
The September 2026 developer token sunset and what replaced it
Google sunset classic developer tokens on September 9, 2026. The current model grants API access at the Google Cloud project level, so older instructions to obtain GOOGLE_ADS_DEVELOPER_TOKEN describe the wrong approval gate. That environment variable no longer belongs in the current credential model. Adding it will not substitute for project access.
The project that owns the OAuth client or service account determines the access tier. Enabling the API grants Test access, which supports read and mutate workflows against test accounts. To work with production accounts, the project needs Explorer, Basic, or Standard access. The account being accessed determines the required access tier, even for requests that merely read data.
The practical change is where approval now sits. Instead of obtaining a developer token, a developer applies for the appropriate access level on the Cloud project. The approval wait may be similar, but the object to inspect is different. This is why an old tutorial can lead to valid OAuth credentials and still leave production calls blocked.
Creating the GCP project and enabling the Google Ads API
Create or select a Google Cloud project in the Cloud Console. Under APIs & Services, open Library, search for “Google Ads API”, and enable it. This grants the project Test access automatically. The Google Ads API overview page shows the current access level and provides the path to apply for a higher tier.
Before going on, check that the tier allows access to the intended account. Test access is enough for test-account work, but it is not production approval. Keeping those environments distinct avoids blaming OAuth for an access-level rejection.
When the default quota or ADC project needs to be specified, set GOOGLE_CLOUD_PROJECT to the project ID. Use the ID, not the display name or project number. That same ID belongs in the MCP host’s environment configuration later. The OAuth client should be created in the project whose access level will govern the calls.
Configuring the OAuth consent screen and creating the right client type
Choose how the server will run before creating the OAuth client. A Desktop application client is the local stdio choice and avoids redirect-URI configuration. A Web application client is required for Cloud Run over Streamable HTTP and needs an authorized redirect URI. Choosing the wrong type means regenerating credentials later.
For a personal local setup, the Desktop path is simpler. For a shared or remote server that clients such as Claude on the web or ChatGPT reach over HTTP, use the Web path. Do not treat a laptop’s credentials as a ready-made multi-user deployment. The transport and client type must agree.
In APIs & Services, open Credentials and select Configure Consent Screen. Choose External unless the deployment is Workspace-domain-only, then supply the app name, user support email, and developer contact email. Add the Google Ads API scope and complete the consent-screen steps before creating the client. After creation, download the client secret JSON file. Keep it outside any public repository because it feeds the credential-generation step.
Generating Application Default Credentials and minting the refresh token
For local stdio, generate the ADC file through the user consent flow. The command form supplied in Google’s guide is gcloud auth application-default login --scopes= --client-id-file=PATH_TO_CLIENT_SECRET_JSON. Replace PATH_TO_CLIENT_SECRET_JSON with the path to the client secret file that was downloaded. The empty scopes argument needs both the adwords and cloud-platform scope values, whose full strings are absent from the supplied command.
Both scopes have a role in this setup. The adwords scope authorizes Google Ads API calls, while cloud-platform covers GCP identity. Omitting either can produce failures that do not clearly identify a scope problem. A successful browser login alone is therefore not proof that the credential has every permission the server needs.
The command opens a browser for consent and prints the saved credential path afterward. On Linux/macOS, an example location is ~/.config/gcloud/application_default_credentials.json. The file contains the refresh token used for later headless access. For the service account alternative, point GOOGLE_APPLICATION_CREDENTIALS to its key JSON file or use --impersonate-service-account with the ADC login command. That route is limited to Google Ads accounts managed under a Google Workspace domain with domain-wide delegation.
Wiring the server into the MCP host configuration file
The host configuration joins the project, executable, and credential path. Under mcpServers, create the google-ads-mcp entry with pipx as its command. Its argument sequence is run, --spec, google-ads-mcp==0.0.6, and google-ads-mcp. Keep each of those arguments separate in the host’s configuration.
In that entry’s environment settings, put the project ID in GOOGLE_CLOUD_PROJECT and the ADC JSON path in GOOGLE_APPLICATION_CREDENTIALS. The latter can be omitted when ADC is stored at the default gcloud location. These values identify different things, so they are not interchangeable. One selects the project, while the other points to the credential file.
For manager account access, also provide GOOGLE_ADS_LOGIN_CUSTOMER_ID without hyphens. Exact names and paths count here because a typo can appear as a generic connection failure. After saving, restart the host so it loads the new server entry. The host should then list the google-ads-mcp tools. Tool discovery shows the host can find the server, but an authenticated tool call is still needed to prove account access.
The headless refresh pattern and what happens after the browser session ends
The browser session starts authorization, but it does not sustain runtime access. Access tokens last a short time, but the stored refresh token lets the server ask Google’s token endpoint for new access tokens. That exchange needs no further browser interaction. The gcloud ADC command handles the offline-access request automatically.
A refresh token lasts a long time, but the access it grants can end. Google’s OAuth documentation describes expiry conditions including 6 months of inactivity and a short window for apps in Testing mode. Tokens can also be revoked through the Google Account security dashboard or programmatically. When a refresh token is no longer valid, a new consent flow is needed to restore access.
Each authorizing advertiser produces a separate OAuth credential, so a service serving many users holds their individual refresh tokens. The deployer owns token storage and lifecycle management. Tokens must never enter prompts, logs, or the model’s context window. The agent should get and pass only opaque references so the credentials themselves stay outside its reasoning context.
Deploying to Cloud Run for remote HTTP access and per-user OAuth
A shared deployment changes more than the server’s address. Build and push a Docker image from the official repository, then deploy it to Cloud Run using streamable-http transport. Use an OAuth 2.0 Web application client ID and client secret in place of the local Desktop/ADC setup. The client’s authorized redirect URI belongs to this remote OAuth setup.
Set GOOGLE_ADS_MCP_OAUTH_CLIENT_ID and GOOGLE_ADS_MCP_OAUTH_CLIENT_SECRET for application-level authentication. Google’s guide says these settings make the server enforce Google OAuth 2.0 on every request and return 401 Unauthorized to unauthenticated callers. Standard AI clients use end-user OAuth. Direct connections therefore require --allow-unauthenticated paired with application-level OAuth. MCP clients can then connect to the Cloud Run HTTP endpoint.
For agencies and B2B platforms, an OAuth proxy maps each user’s session to that user’s refresh token before forwarding calls. Each user completes a separate consent flow. This prevents the local single-user credential model from becoming the shared service’s identity model. The deployer remains responsible for the container, Cloud Run service, proxy, token storage, and refresh lifecycle. Hosting on Cloud Run does not transfer those duties to Google.
Common 401 failure patterns and how to trace them to their auth layer
Start with the layer named by the failure. If a production call returns AuthorizationError.CLOUD_PROJECT_NOT_APPROVED_FOR_PRODUCTION, inspect the project’s access level on the Google Ads API overview page. Regenerating a refresh token does not grant project approval. If the remote endpoint rejects an unauthenticated caller with HTTP 401, distinguish that request-level OAuth rejection from an API call that reached Google Ads and failed authorization.
If tool calls fail after ADC generation, revisit the scopes. An omitted adwords scope requires rerunning the login command with both required scopes and regenerating the ADC file. If the failure follows a deployment change, inspect the OAuth client type instead. Desktop is for local stdio, and Web application is for remote HTTP. A transport mismatch is not repaired by changing the project’s access tier.
If access worked and then stopped, inspect refresh-token validity. Revocation or changed Google account security settings can break headless refresh, requiring a new consent flow and ADC file. Manager-account permission errors follow a different branch. Check GOOGLE_ADS_LOGIN_CUSTOMER_ID and supply the 10-digit ID without hyphens. To finish, restart the host, confirm tool discovery, and call list_accessible_customers as the smoke test for authenticated access.
What a working authenticated MCP connection enables for autonomous ad operations
Successful authentication gives the agent live data to reason over. It can call list_accessible_customers to discover accessible accounts, then chain search calls using GAQL for campaign metrics, keyword performance, asset strength signals, and budget pacing. Those results can feed a broader automated workflow without a person opening the Ads UI. The server keeps the credentials while the findings from the account go into the model’s context.
Supported mutations have a separate confirmation boundary. Google’s guide specifies validate_only=True during the propose stage and a checksum digest that must match between propose and confirm calls. This applies to the server’s supported changes, including asset creation and label management. Authentication permits access, but it does not remove that validation workflow.
For campaign creation, bid adjustment, or pausing, the same OAuth credential and project access level apply when the agent switches to a direct API client. The MCP setup is therefore not discarded when the workflow needs more control.


