Skip to content

Commit

Permalink
Add docstrings to auth.oauth() and auth.service_account()
Browse files Browse the repository at this point in the history
  • Loading branch information
burnash committed Apr 28, 2020
1 parent a756dd6 commit 326667c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Top level
---------

.. autofunction:: oauth
.. autofunction:: service_account
.. autofunction:: authorize

Client
Expand Down
14 changes: 14 additions & 0 deletions gspread/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ def store_credentials(


def oauth(scopes=DEFAULT_SCOPES, flow=local_server_flow):
"""Authenticate with OAuth Client ID.
:param list scopes: The scopes used to obtain authorization.
:param function flow: OAuth flow to use for authentication.
:rtype: :class:`gspread.client.Client`
"""
creds = load_credentials()

if not creds:
Expand All @@ -101,6 +108,13 @@ def oauth(scopes=DEFAULT_SCOPES, flow=local_server_flow):
def service_account(
filename=DEFAULT_SERVICE_ACCOUNT_FILENAME, scopes=DEFAULT_SCOPES
):
"""Authenticate using a service account.
:param str filename: The path to the service account json file.
:param list scopes: The scopes used to obtain authorization.
:rtype: :class:`gspread.client.Client`
"""
creds = ServiceAccountCredentials.from_service_account_file(
filename, scopes=scopes
)
Expand Down

0 comments on commit 326667c

Please sign in to comment.