Google Search Console API key: why OAuth or a service account is required
Google Search Console rejects plain API keys for private data. Pick between OAuth 2.0, a service account, or a Hosted gscdump API key.
Google Search Console does not accept an API key for Search Analytics, URL Inspection, Sitemaps, or Sites requests. Google documents in Authorize Requests that every request to the Search Console API must use OAuth 2.0. No other authorization protocol is supported.
A Google Cloud API key identifies your project for billing and quota, as Google documents in Manage API keys. It does not prove which user or account has permission to read a private Search Console property.
Why Google's docs mention API keys
Google's Prerequisites and Authorize Requests pages cover two separate APIs under the same heading:
- Search Console API serves private property data (Search Analytics, URL Inspection, Sitemaps, Sites). Every call requires an OAuth 2.0 access token with
https://www.googleapis.com/auth/webmasters.readonlyorhttps://www.googleapis.com/auth/webmasters. - Search Console Testing Tools API serves public test data and accepts either an API key (
?key=yourAPIKey) or an access token.
Developers often create a Google Cloud API key after reading the Testing Tools section, then append ?key=... to a Search Analytics URL and get an authorization error. The key works for the Testing Tools API only.
Pick the right credential for your setup
Choose the credential based on who owns the Search Console properties and where your code runs.
| Credential | Works with Google Search Console API? | Best fit | Main trade-off |
|---|---|---|---|
| OAuth 2.0 user client | Yes | Multi-user web apps and interactive local tools | Requires consent screen, redirect URI, and refresh token handling |
| Google service account | Yes (two-legged OAuth 2.0) | Automated scripts and servers reading your own properties | You must add the service account email to every property in Search Console |
| Google Cloud API key | No (Testing Tools API only) | Public Testing Tools requests | Rejected on all private Search Console endpoints |
| gscdump Hosted API key | Calls gscdump Hosted v1, not Google directly | Apps and scripts reading synced Sites without managing Google OAuth | Uses Authorization: Bearer <key> against gscdump; requires a connected Site |
Option 1: use a service account for your own properties
If you only need automated access to properties you control, a service account removes the interactive browser consent screen. Google documents this flow as server-to-server ("two-legged OAuth") in Using OAuth 2.0 for Server to Server Applications.
- In Google Cloud, enable the Google Search Console API.
- Create a service account and copy its email address (for example
gsc-reader@your-project.iam.gserviceaccount.com). - Generate and store its JSON key securely on your server or local machine.
- Open Google Search Console, select each property you want to query, go to Settings, then Users and permissions, and add the service account email with Restricted or Full permission.
- Exchange a signed JWT for an OAuth 2.0 access token through your Google client library, requesting
https://www.googleapis.com/auth/webmasters.readonly.
Two rules trip up most first-time setups. First, creating the service account in Google Cloud grants zero Search Console access until you add its email to each property. Second, keep the JSON key outside version control and browser bundles.
If you want a Local workflow with your own credentials, @gscdump/cli runs on your machine using your service account or OAuth client. It never uses gscdump's OAuth client or Google quota. See Choose access for the Local setup sequence.
Option 2: use OAuth 2.0 for other people's properties
If users connect their own Search Console properties to your app, use standard OAuth 2.0. Your application redirects each user to Google, stores their refresh token on your server, and refreshes short-lived access tokens before calling the API.
Watch for the Testing-mode expiry limit before shipping. External Google OAuth apps left in Testing publishing status receive refresh tokens that expire after seven days for Search Console scopes. Follow the Search Console API authentication guide for redirect URI rules, token refresh, and invalid_grant diagnosis.
Option 3: skip Google OAuth with a gscdump API key
A gscdump API key is a credential for gscdump's Hosted API, separate from Google Cloud. Once a Site is connected on gscdump.com, gscdump handles Google OAuth consent, token refresh, and syncing on the server.
Your server sends that key to Hosted v1 with Authorization: Bearer <key>, or passes it to @gscdump/sdk through credential: () => key. Never send a gscdump key directly to googleapis.com, and never expose it in a URL or browser bundle.
curl --fail-with-body --get \
"https://gscdump.com/api/partner/v1/sites/${GSCDUMP_SITE_ID}/analytics/coverage" \
--data-urlencode 'startDate=2026-10-01' \
--data-urlencode 'endDate=2026-10-28' \
--header "Authorization: Bearer $GSCDUMP_API_KEY"Read Set up keys and scopes for hosted data for user keys, partner keys, and fixed scopes.
Next steps
- Already have a Google OAuth token? Make your first Search Analytics API request.
- Building a web app with Google OAuth? Follow the OAuth authentication walkthrough or call Google directly in TypeScript with Direct first result.
- Building Search Console into a product for multiple users? See gscdump for builders.
- Connecting an agent without configuring Google Cloud? Start at gscdump MCP.