11/18/2026
GA4 and gcloud: Fixing 'This App Is Blocked'
Short answer: You cannot reach Google Analytics 4, Search Console or Tag Manager with a plain gcloud auth login token. That token carries Google Cloud scopes, and when we asked it for an Analytics scope on 08/27/2026 the login ended at "This app is blocked." Google documents that error for scopes its default setup does not support. Use a service account (a key file, or impersonation) or your own OAuth client, pass the scope you need, and have a person grant that identity access inside each product once. Everything after that grant is a command you can store and rerun.
The two errors, in the order we hit them
We asked for this from chat on 08/27/2026: fetch the GA4 property for each site through the command line. The Google Cloud CLI was already signed in, and the first call failed. Then the suggested fix failed differently.
| Step | What we saw | What it means |
|---|---|---|
| Call the Analytics Admin API with the gcloud token | ACCESS_TOKEN_SCOPE_INSUFFICIENT |
The token reached the API but carried no Analytics scope |
| Run the consent command to add that scope | "This app is blocked. This app tried to access sensitive info in your Google Account." | The login was refused before any token was issued |
The agent working the session did not retry. It read the second message as Google refusing gcloud's built-in client for a restricted scope, and it was not something Aaron had done wrong. We did not record the exact flags of that consent command, so we cannot say whether one specific command line still fails today.
Why the gcloud login cannot carry the scope
Google documents this in its own ADC troubleshooting page, and it matches what we saw. A "This app is blocked" or "Access blocked: Authorization Error" at login usually means you asked the default setup command for scopes it does not support, typically for products outside Google Cloud.
The gcloud auth application-default print-access-token reference says the same thing from the other side. For an end-user account the scopes must come from a short list (openid, userinfo.email, cloud-platform, sqlservice.login) or be ones you gave to login --scopes. For a service account, --scopes is simply supported.
That asymmetry is why the fix works. A person logging in through gcloud's client is capped on scopes. A service account is not.
Three credentials that work
Google Cloud's ADC troubleshooting page names two ways around the block, your own OAuth client and service-account impersonation. A plain service-account key is the third.
| Route | How | Person needed for | Caveat |
|---|---|---|---|
| Your own OAuth client | gcloud auth application-default login with --client-id-file=client.json --scopes=... |
Consent screen and client ID (Cloud Console), plus a browser consent | An external app in "Testing" status gets refresh tokens that expire in 7 days |
| Service account key | GOOGLE_APPLICATION_CREDENTIALS points at a JSON key |
Granting the account access in each product | The key file is a password: keep it out of git |
| Service account impersonation | gcloud auth application-default login --impersonate-service-account=EMAIL --scopes=... |
Granting the account access, and the Token Creator role for you | No key file, but more setup |
What we ran: Search Console through a service account, which worked. For GA4 the service-account grant took two attempts: it was added in Google Analytics on 09/30/2026 and then listed Next Day Videos' property, but we have not recorded a GA4 report run that way. We did not test the other two routes.
Set up the service account
Everything here is gcloud services enable, gcloud iam service-accounts create and gcloud iam service-accounts keys create, with the flags checked against gcloud 580.0.0's own help.
gcloud services enable analyticsdata.googleapis.com analyticsadmin.googleapis.com \
searchconsole.googleapis.com tagmanager.googleapis.com
gcloud iam service-accounts create reporting-reader --display-name="Reporting reader"
gcloud iam service-accounts keys create reporting-reader.json \
--iam-account=reporting-reader@PROJECT_ID.iam.gserviceaccount.com
Enabling the GA4 Data API this way worked from chat on 08/12/2026. Now a person adds reporting-reader@PROJECT_ID.iam.gserviceaccount.com as a user in each product (the table near the end lists where). Then point the environment at the key. The commands are bash; Git Bash on Windows runs them, and in cmd the variable is set with set.
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/reporting-reader.json
Read GA4 from the terminal
The Analytics Data API and the Analytics Admin API take the analytics.readonly scope. Mint a token with that scope, list every property the account can see, then run a report.
TOKEN=$(gcloud auth application-default print-access-token \
--scopes=https://www.googleapis.com/auth/analytics.readonly)
curl --fail-with-body -H "Authorization: Bearer $TOKEN" \
https://analyticsadmin.googleapis.com/v1beta/accountSummaries
curl --fail-with-body -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"dateRanges":[{"startDate":"28daysAgo","endDate":"today"}],"dimensions":[{"name":"city"}],"metrics":[{"name":"activeUsers"}]}' \
https://analyticsdata.googleapis.com/v1beta/properties/PROPERTY_ID:runReport
accountSummaries.list returns what the caller can access, which is why granting the account once at the Analytics account level beats granting each property. Google's help says a user added at the account level reaches every property in it. The numeric property ids had been empty for all five of our sites, so the plan was to list them in one call after a single account-level grant. runReport is the same method the vendor's own quickstart calls.
Keep --fail-with-body. Plain curl exits 0 on a 403, as the curl exit-code post here shows, so a script would call a scope error a success.
Search Console: queries, inspection, sitemaps
The Search Console API wants a different scope, so it needs its own token. Use webmasters.readonly for reading and webmasters for submitting a sitemap.
TOKEN=$(gcloud auth application-default print-access-token \
--scopes=https://www.googleapis.com/auth/webmasters.readonly)
curl --fail-with-body -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"startDate":"2026-09-01","endDate":"2026-09-30","dimensions":["query"],"rowLimit":10}' \
"https://www.googleapis.com/webmasters/v3/sites/sc-domain%3Aexample.com/searchAnalytics/query"
For a domain property the site is sc-domain:example.com, URL-encoded in the path. A URL-prefix property is the full address with its trailing slash. urlInspection.index.inspect takes inspectionUrl and siteUrl in a POST body to https://searchconsole.googleapis.com/v1/urlInspection/index:inspect, and sitemaps.submit is a PUT with no body.
The published limits matter before you loop: URL inspection allows 2,000 queries a day and 600 a minute per site.
Our own run: the service account saw three of our sites but not nextdayvideos.com until Aaron added it under Settings, Users and permissions on 08/30/2026, a grant the agent estimated at two minutes. The first query then showed zero impressions for the site across 16 months.
Tag Manager: publish a change in three calls
The Tag Manager API splits the work by scope, so a script that edits cannot publish unless you gave it the publish scope too.
| Step | Call | Scope |
|---|---|---|
| Add the tag in a workspace | workspaces.tags.create |
tagmanager.edit.containers |
| Freeze the workspace into a version | workspaces:create_version |
tagmanager.edit.containerversions |
| Make that version live | versions:publish |
tagmanager.publish |
create_version also deletes the workspace it came from. The container user needs the Publish permission level to do the last step, since Approve can create versions but not publish (Tag Manager help). The API allows 10,000 requests a day and 0.25 queries a second per project (limits). Test on a throwaway container: the developer guide warns that destructive calls have no confirmation and no undo.
What still needs a person
The table lists the steps that stayed manual for us, or that Google's documentation puts behind a person.
| Step | Why it stays manual | Source |
|---|---|---|
| Add the service account to GA4 | Only an Administrator can add users | Analytics help |
| Add it to Search Console | The Users and permissions page is visible only to property owners | Search Console help |
| Add it to Tag Manager | Users are added under User Management, with a permission level per container | Tag Manager help |
| OAuth consent screen and client ID | The agent told us there was no CLI equivalent, and we did both in the Cloud Console on 08/12/2026 | Our session record; not checked against Google's docs |
| Test whether a live URL is indexable | The inspection API reports only the version already in Google's index | Inspect reference |
| Ask Google to index an ordinary page | The Indexing API is limited to pages with JobPosting or livestream (BroadcastEvent) markup | Indexing API quickstart |
| Antivirus that breaks the login | Avast's TLS interception silently broke gcloud's token exchange until Aaron added a process exclusion | Our session record |
Handing the terminal to an assistant
On 08/12/2026 Aaron asked a Claude Code session for gcloud access, giving two reasons: the Google Cloud admin console is slow and clunky, and commands can be stored, referenced and reused. The session installed gcloud, signed in through the browser consent (no password typed into the session), set the default project and enabled the GA4 Data API. It also wrote the setup and its traps into a reusable skill.
The assistant handled the commands; the grants stayed with Aaron. This is one part of the No Login Required series, which starts with Will We Even Need Admin Panels? on belchamber.us.
Ask for the response status on every call, because "done" from an assistant is a claim. A five-minute test that catches an AI agent skipping a step shows one way to check it.

Let my Claude help your Claude
If you want a second pair of eyes on how your own setup uses AI-assisted development, that's what this is: me, personally, for AI specifically. Broader business growth and technology consulting is Brandager's own team.
Researched and drafted with AI, then reviewed and edited by the site's editors.