Skip to content

Fix suppressKeyFileNotice for impersonated ADC credentials #9154

@nickjenkin

Description

@nickjenkin

When using impersonated ADC credentials with the PHP SDK, an error is thrown:

A keyfile was given, but it does not contain a project ID. This can indicate an old and obsolete keyfile, in which case you should create a new one. To suppress this message, set suppressKeyFileNotice to true in your client configuration. To learn more about generating new keys, see this URL: https://cloud.google.com/iam/docs/creating-managing-service-account-keys#creating_service_account_keys

Setting suppressKeyFileNotice=>true allows the impersonated ADC credentials to work. However this check is for old service accounts, and should be modified to account for impersonated credential files.

Environment details

  • OS: Linux
  • PHP version: 8.4.7
  • Package name and version: Core/src
    /ClientTrait.php

Steps to reproduce

  1. Use an impersonated ADC credential e.g. "gcloud auth application-default login --impersonate-service-account=..."
  2. (Docker) Set:GOOGLE_APPLICATION_CREDENTIALS=~/.config/gcloud/application_default_credentials.json and
    GOOGLE_CLOUD_PROJECT=xyz

Code example

Errors:

        $storage = new StorageClient();

Works:

        $storage = new StorageClient(['suppressKeyFileNotice' => true]);

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions