-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add AWS credential source #474
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks great! I've reviewed the changes and tested them on an Amazon EC2 machine to ensure they work correctly without failures. And an access token is generated successfully which can be used to make other calls.
However, I'd like to bring up a potential improvement and concern:
Improvement:
It might be a good idea for later into the PHP Client Library to better handle the project_id
field. Currently, the AWS JSON key doesn't seem to include include project_id
or projectId
by default, unlike other authentication flows (e.g., service accounts) that do contain this key. While the audience URL does include a project number, there may be cases where having the project_id
explicitly in the JSON key could be beneficial.
Concern:
I've noticed that the StorageClient
may encounter issues in situations where users rely on automatic detection of the project_id
. Other clients may also typically expect this field to be provided explicitly or get derived automatically from the JSON key. In the absence of the project_id
, these cases could potentially lead to failures in user's application.
How I generated the token:
use Google\Auth\Credentials\ExternalAccountCredentials;
putenv(sprintf('GOOGLE_APPLICATION_CREDENTIALS=%s/%s', __DIR__, 'key.json'));
$creds = ApplicationDefaultCredentials::getCredentials('https://www.googleapis.com/auth/cloud-platform');
print_r($creds->fetchAuthToken())
Credentials return the "quota project ID", which is something different. However, it may be a good idea to have
We've gone through a few iterations of "project ID detection", but it's a complex problem because the various client libraries do it a little differently (env var, client option, credential field, etc). However, this is a separate issue that is out of scope of this PR. |
@vishwarajanand I stand corrected, it IS supported (via I'll do some more research here... |
Depends on #473