Skip to content
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

Simplified OAuth2 flow #762

Merged
merged 3 commits into from
Apr 17, 2020
Merged

Simplified OAuth2 flow #762

merged 3 commits into from
Apr 17, 2020

Conversation

burnash
Copy link
Owner

@burnash burnash commented Apr 15, 2020

This is a first attempt to implement a simplified authentication for gspread. Inspired by excellent gspread-pandas I'd like to cut down the boilerplate for constructing credentials, so you can get the authorized client instance in your code with just:

import gspread
gc = gspread.oauth()

On the first run, this will look for OAuth 2.0 Client credentials in ~/.config/gspread/credentials.json, open a browser window with the application authorization request, get the user's consent and store authorized credentials in the config directory. Next runs will use stored credentials.

Open questions:

  1. Credentials security.
  2. Default scope.
  3. With this added convenience, should client credentials replace service accounts as recommended flow in the docs. This is related to (1) and (2) since a service account does not have access to any spreadsheet unless a spreadsheet is explicitly shared with this account. Using OAuth 2.0 Client credentials, on the other hand, gives the script direct access to the user data.

`gspread.auth.oauth()` uses `InstalledAppFlow` from 
`google_auth_oauthlib` to implement OAuth 2.0 Authorization flow for 
installed applications.
@burnash burnash marked this pull request as draft April 15, 2020 11:46
@burnash burnash requested a review from aiguofer April 15, 2020 11:46
@burnash burnash changed the title [WIP] Simplified OAuth2 flow Simplified OAuth2 flow Apr 15, 2020
@burnash burnash marked this pull request as ready for review April 16, 2020 14:37
@burnash burnash added this to the 3.5.0 milestone Apr 17, 2020
@burnash
Copy link
Owner Author

burnash commented Apr 17, 2020

Ok, let's merge it and try a soft launch :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to use gspread when authenticating through google OAuth? Must a spreadsheet be shared?
1 participant