token variant

This commit is contained in:
JiriUhlir
2026-06-22 05:26:20 +02:00
parent 125b112967
commit 28b29b8331
5 changed files with 77 additions and 10 deletions
+6 -2
View File
@@ -10,11 +10,15 @@ Token has precedence over the service account:
| Header | Meaning |
| --- | --- |
| `X-GA-Access-Token` | Ready OAuth2 access token, used directly as `Authorization: Bearer`. |
| `Authorization` | Standard `Authorization: Bearer <token>` header — equivalent alternative to `X-GA-Access-Token`. |
| `X-GA-Credentials` | **Base64** of a Google service-account JSON key. The proxy mints a short-lived token (scope `https://www.googleapis.com/auth/analytics.readonly`) via `google-auth` and caches it in memory until ~60 s before expiry. |
| `X-GA-Quota-Project` | Optional GCP project id → upstream `x-goog-user-project`. |
At least one of `X-GA-Access-Token` / `X-GA-Credentials` is required (otherwise
`401 missing_credentials`).
A ready access token can be supplied either in `X-GA-Access-Token` or in the
standard `Authorization: Bearer <token>` header. At least one credential source
(token header, `Authorization: Bearer`, or `X-GA-Credentials`) is required,
otherwise `401 missing_credentials`. Priority when several are present:
`X-GA-Access-Token``Authorization: Bearer``X-GA-Credentials`.
The service account (or token) must have access to the GA4 property — add its
`client_email` as a viewer in GA Admin → Property Access Management.