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

Add auth.service_account() #768

Merged
merged 1 commit into from
Apr 27, 2020
Merged

Add auth.service_account() #768

merged 1 commit into from
Apr 27, 2020

Conversation

burnash
Copy link
Owner

@burnash burnash commented Apr 24, 2020

Simplify auth with service accounts. This PR adds gspread.service_account() which wraps Credentials.from_service_account_file cutting down initialization code.

So instead of

import gspread
from google.oauth2.service_account import Credentials

scopes = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']

credentials = Credentials.from_service_account_file(
    'path/to/the/downloaded/file.json', 
    scopes=scopes
)

gc = gspread.authorize(credentials)

You put your service account key in ~/.config/gspread/service_account.json and service_account() does the rest:

import gspread
gc = gspread.service_account()

@honzajavorek
Copy link

Awesome!

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.

2 participants