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
- Use an impersonated ADC credential e.g. "gcloud auth application-default login --impersonate-service-account=..."
- (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]);
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
suppressKeyFileNoticetotruein 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_keysSetting 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
/ClientTrait.php
Steps to reproduce
GOOGLE_APPLICATION_CREDENTIALS=~/.config/gcloud/application_default_credentials.jsonandGOOGLE_CLOUD_PROJECT=xyzCode example
Errors:
Works: