A script needed to read a Google API (Search Console) for a project whose service account already existed. Creating the service-account key failed with:
A script needed to read a Google API (Search Console) for a project whose service account already existed. Creating the service-account key failed with:
服务账号密钥创建功能已停用
已对您的组织强制执行一项组织政策,该政策会阻止创建服务账号密钥。
强制执行的组织政策 ID: iam.disableServiceAccountKeyCreationThere is no client-side workaround for a blocked key: the key is the credential, and the policy removes it. A second wall followed immediately after switching to a user-consent flow:
禁止访问:"gsc-reader" 只能在所属组织内使用
错误 403: org_internal— the OAuth consent screen's user type was Internal (organization only), while the account signing in was a personal Gmail outside that organization. The scope was never the problem; the identity boundary was.
Three different layers each say "not allowed" and they are easy to conflate:
iam.disableServiceAccountKeyCreation blocks downloading a key, which is one way to prove an identity. It does not block the API.Internal restricts the client to accounts inside the organization; an outside account is refused at the [REDACTED:bearer_token] with org_internal before any code is issued. This is a console setting, not something a client can fix.The trap is that the first failure looks like "the project is locked down", so the natural next step is to ask an org admin to disable the policy. That is slower, needs someone else, and is not necessary.
iam.disableServiceAccountKeyCreation is in the error, do not try other key formats.https://www.googleapis.com/auth/webmasters.readonly here): create an OAuth installed-app/desktop client in that project, then run a loopback consent and store the refresh token.Internal, the operator must change it to External and add themselves as a test user (Testing status works for sensitive scopes without verification). This is the one step that cannot be automated.chmod 0600 is ignored (rwxrwxrwx), so location is the control, not the mode — keep it in a git-ignored directory, never in the repository.$ python3 puller.py --oauth-credentials <stored.json> --list-sites
1 property visible to this credential:
https://misakanet.org/ [siteOwner]— a successful sites.list with siteOwner proves the identity, the scope and the property id in one call. A zero-row searchAnalytics answer afterwards is a data question (a property verified minutes earlier has no history), not an [REDACTED:bearer_token]
sites.list returns the expected property with siteOwner, and a searchAnalytics query returns 200 (zero rows is legitimate for a freshly verified property).