Skip to content

Authentication and tokens

Masthead provides several programmatic interfaces, each requiring a specific authentication method:

  • BigQuery shared dataset: Authenticates using your Google Cloud IAM credentials. For details, see the BigQuery shared dataset setup guide.
  • Resource management API: Authenticates using static API tokens for the Masthead Terraform provider. For details, see the Resource management API configuration guide.
  • MCP server: Authenticates using Google SSO for interactive users or service account token exchanges for headless environments.

The Masthead MCP server supports two authentication modes depending on your environment.

If you use interactive developer tools like Claude Code, Codex, or Google Antigravity on your local workstation, the client automatically handles authentication:

  1. On first launch, the client opens a browser tab.
  2. Log in using your Google SSO credentials.
  3. The client caches the returned JWT locally for subsequent requests.

If you run MCP clients in headless environments like Google Cloud Build, GitHub Actions, or background daemon processes, you must exchange a Google Cloud service account token for a Masthead access token.

Create a service account in your Google Cloud project and register its email address with your Masthead tenant.

Exchange your service account’s Google ID token for a Masthead access token. The returned token is valid for 1 hour.

To exchange the token using the Google Cloud CLI and curl, run the following commands:

Terminal window
# 1. Mint Google ID token (--include-email is required)
IDT=$(gcloud auth print-identity-token \
--impersonate-service-account="your-bot@YOUR_PROJECT.iam.gserviceaccount.com" \
--audiences=https://sso.mastheadata.com \
--include-email)
# 2. Exchange for Masthead Access Token
TOKEN=$(curl -s -X POST https://sso.mastheadata.com/oauth2/token \
-d 'grant_type=urn:ietf:params:oauth:grant-type:token-exchange' \
-d 'subject_token_type=urn:ietf:params:oauth:token-type:id_token' \
-d 'client_id=service-account' \
--data-urlencode "subject_token=$IDT" | jq -r .access_token)

Pass the returned token in the static Authorization header of your client configuration. For example, to add the server in Claude Code:

Terminal window
claude mcp add --transport http masthead https://mcp.mastheadata.com/mcp \
--header "Authorization:Bearer $TOKEN"