Create a Credentials object from the service account's credentials and the scopes your application needs access to.
https://developers.google.com/identity/protocols/oauth2/service-account#authorizingrequests
from google.oauth2 import service_account
SCOPES = ['https://www.googleapis.com/auth/sqlservice.admin']
SERVICE_ACCOUNT_FILE = '/path/to/service.json'
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
SAMPLE_RANGE_NAME = 'Sheet1!A:Z'
# You can use A:AA, A:AB and so on...
How to solve this error?
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://sheets.googleapis.com/v4/spreadsheets/ returned "The caller does not have permission">
Solution
Share the sheet permission with 'Service Accounts's' email.