Google Cloud / Editorial solution guide
Investigate unexpected Application Default Credentials
Trace the application credential source, principal and target before changing Google Cloud IAM.
Read-only knowledge base · No public comments
Recognize the symptoms
A fictional application receives a permission denied error, while a gcloud command succeeds on the same workstation. In a deployed service, the expected attached service account also appears not to have made the request. The two observations may involve different credential contexts.
Understand the likely causes
- Local Application Default Credentials and gcloud CLI credentials are distinct. An environment-specified credential file, local ADC file or attached service account can be selected according to the documented search order. A correct principal can still lack permission on the actual resource.
Capture the request safely
Record the application environment, target project, service operation, resource, time and sanitized error or request identifier. Record the expected principal and credential mechanism without copying tokens, credential files or private keys. Compare the application’s request with the successful CLI request; different targets or operations are separate hypotheses.
Trace credential discovery
Under an approved investigation, determine whether the application has an environment-specified credential configuration, local ADC credentials or an attached service account available through metadata. Consult the current ADC search order and the client library’s behavior. Do not assume a credential file is necessarily a service account key, and do not open or export secret material into a ticket.
Compare identity and authorization
Use approved audit or diagnostic evidence to identify the principal that made the failing request. Compare it with the expected workload identity, project and resource. If the principal matches, inspect the exact IAM permission, role binding and applicable conditions with the owner. A successful token or CLI request does not authorize a different principal or resource.
Correct only the identified cause
If an unintended credential source takes precedence, propose a reviewed correction to the runtime configuration. If the target project is wrong, correct the target rather than broadening access. If a permission is genuinely missing, request the smallest appropriate grant with a rollback and negative test. Preserve the original evidence and avoid replacing credentials indiscriminately.
Verify the fix
In an authorized isolated lab, repeat the intended read-only request with the verified application context and a synthetic resource. Confirm the expected principal and a successful result, then test a neighboring request that should remain denied.
Record sanitized target, identity and timestamps without storing tokens. Verify the deployed environment separately from the workstation; a local success does not prove production credential selection.
Keep it from recurring
- Document expected credential sources and identities by environment, avoid unnecessary long-lived keys, and test allowed and denied access. Monitor changes to runtime configuration and IAM bindings through the normal review process.