Skip to content

OAuth 2.0 credentials ignored - _create_credentials() only uses google.auth.default() #16

@Teake1404

Description

@Teake1404

Bug Description

The _create_credentials() function in ads_mcp/utils.py only uses google.auth.default() which looks for GCP Application Default Credentials (service accounts, gcloud auth). This ignores OAuth 2.0 credentials (client_id, client_secret, refresh_token) that are the standard authentication method for Google Ads API.

Steps to Reproduce

  1. Configure MCP with valid OAuth 2.0 credentials in Claude Desktop config:
{
  "mcpServers": {
    "google-ads": {
      "command": "uvx",
      "args": ["google-ads-mcp"],
      "env": {
        "GOOGLE_ADS_DEVELOPER_TOKEN": "xxx",
        "GOOGLE_ADS_CLIENT_ID": "xxx.apps.googleusercontent.com",
        "GOOGLE_ADS_CLIENT_SECRET": "xxx",
        "GOOGLE_ADS_REFRESH_TOKEN": "xxx",
        "GOOGLE_ADS_LOGIN_CUSTOMER_ID": "xxx"
      }
    }
  }
}

Attempt to use any MCP tool
Get authentication error because google.auth.default() can't find GCP ADC
Expected Behavior
The MCP should use OAuth 2.0 credentials when provided via environment variables.

Suggested Fix
Replace google.auth.default() with GoogleAdsClient.load_from_dict():

def _create_credentials() -> GoogleAdsClient:
    credentials = {
        "developer_token": os.environ.get("GOOGLE_ADS_DEVELOPER_TOKEN"),
        "client_id": os.environ.get("GOOGLE_ADS_CLIENT_ID"),
        "client_secret": os.environ.get("GOOGLE_ADS_CLIENT_SECRET"),
        "refresh_token": os.environ.get("GOOGLE_ADS_REFRESH_TOKEN"),
        "login_customer_id": os.environ.get("GOOGLE_ADS_LOGIN_CUSTOMER_ID"),
        "use_proto_plus": True,
    }
    return GoogleAdsClient.load_from_dict(credentials)

Environment
google-ads-mcp version: latest (installed via uvx)
Python version: 3.14
OS: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions