Open mwilliammyers opened 4 years ago
I wonder if we should rename from_credentials
to with_credentials
and make it with_application_default_credentials
...
I don't really know what's best here.
According to this page from the official docs, the different official client libraries all do it in a slightly different way.
I picked Client::new()
because of Golang's client, who does it like this:
// equivalent to our `Client::new()`
storage.NewClient(ctx)
// equivalent to our `Client::from_credentials(creds)`
storage.NewClient(ctx, option.WithCredentials(creds))
Maybe completing ADC can be done by extending/changing ApplicationCredentials
?
I don't know because I never used GCE nor App Engine.
Currently these 3 lines are in all clients. How about extracting it to a function in the authorize module? Then if we want to support ADC in future, we only update one place.
What do you think about renaming
new()
tofrom_application_default_credentials()
? I was a little surprised when I found out thatnew
depended on theGOOGLE_APPLICATION_CREDENTIALS
env var being set. I also think it mirrorsfrom_credentials
nicely.This would also set us up to implement the entire Application Default Credentials (ADC) flow in the future. This would require us querying metadata servers (on GCE or App Engine etc) to get credentials if the
GOOGLE_APPLICATION_CREDENTIALS
env var is not found.