Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Requirements: Python 3.8+.
```python
import gspread

# First you need access to the Google API. Based on the route you
# chose in Step 1, call either service_account(), oauth() or api_key().
gc = gspread.service_account()

# Open a sheet from a spreadsheet in one go
Expand Down
17 changes: 13 additions & 4 deletions docs/oauth2.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
Authentication
==============

To access spreadsheets via Google Sheets API you need to authenticate and authorize your application.
To access spreadsheets your application needs to authenticate itself with the Google Sheets API. Choose from the following options.

#. Create an :ref:`API key <api-key>` if you’d like to only open public spreadsheets.
#. (or) Create a :ref:`OAuth Client ID <oauth-client-id>` if you’d like to access spreadsheets on behalf of end users (including yourself).

- When your application runs, it will prompt the user to authorize it.

#. (or) Create a :ref:`Service Account <service-account>` to access spreadsheets as a standalone bot.

- Service accounts get their own email address, so can be authorized by sharing the Sheet with the account in the same way it is shared with a person.
- Service accounts don't need any explicit permissions to access Sheets that are shared to "anyone with the URL".

An API Key is the easiest option, but to access private Sheets you need authorization. To provide that interactively, use an OAuth Client ID. To pre-configure authorization, use a Service Account.

* If you plan to access spreadsheets on behalf of a bot account use :ref:`Service Account <service-account>`.
* If you'd like to access spreadsheets on behalf of end users (including yourself) use :ref:`OAuth Client ID <oauth-client-id>`.
* If you'd like to **only** open public spreadsheets use :ref:`API key <api-key>`

.. _enable-api-access:

Expand Down