nithinmurali / pygsheets

Google Sheets Python API v4
https://pygsheets.readthedocs.io/en/latest
Other
1.5k stars 220 forks source link

Use google.auth.Credential for authorization #555

Closed steveoh closed 2 years ago

steveoh commented 2 years ago

Is your feature request related to a problem? Please describe.

I can't seem to find a way to use pygsheets in a GCP cloud function that can use the default application credentials of the function. pygsheets gives me a lot of options to use service account keys but I do not want to have to manage a service account key, rotate it, etc.

Describe the solution you'd like

When running in GCP I'd like to either be able to use the google.auth.Credential object to authorize pygsheets or have a parameterless constructor that delegates to google.auth.default().

Any other info

Is there currently a way to use the results of credentials, project = google.auth.default()

steveoh commented 2 years ago

Ok tried it and saw this works great

        credentials, project = google.auth.default()
        gc = pygsheets.authorize(custom_credentials = credentials)