ThouCheese / cloud-storage-rs

A crate for uploading files to Google cloud storage, and for generating download urls.
MIT License
124 stars 87 forks source link

Support `authorized_user` #113

Open kosta opened 2 years ago

kosta commented 2 years ago

Would you be willing to support more authentication types? Especially authorized_user?

I wrote a small CLI tool that I like to run locally. It would be much easier to adopt if cloud-storage could leverage the existing authentication of the gcloud command-line tool, which seems to write ~/.config/gcloud/application_default_credentials.json with content like this:

{
  "client_id": "...some email",
  "client_secret": "...some random string",
  "quota_project_id": "...some project id",
  "refresh_token": "...some random string",
  "type": "authorized_user"
}

Would you be interested in a PR that is able to read this file instead of only ServiceAccounts?

(Skimming through the code, I would probably make ServiceAccount part of an enum that serde distinguishes by the type).

ThouCheese commented 2 years ago

Sure such a change would definitely be welcome! Although judging from #114 there is also demand for a more comprehensive way to customise authentication than just adding variants to the ServiceAccount data type.