0

I am new to API's and i am trying to create a google sheet using python. I am able to create google sheet but unable to view/edit(Access issue). I am using Service Account in API's. Please help me in modifying the code to access the created sheets.

Here is the sample code i am using to create one.

service = discovery.build('sheets', 'v4', credentials=credentials)

spreadsheet_body = {
}

request = service.spreadsheets().create(body=spreadsheet_body)
response = request.execute()
1
  • What do you mean by "view it"? Which scopes do you have? Please provide your full code including authentication and service account builder. Commented May 5, 2020 at 15:36

1 Answer 1

0
  • Most likely you are creating the sheet as the service account - by default on its Drive, this is why you have issues accessing it.
  • If instead you want to create a sheet on YOUR drive, you need to use impersonation:

  • After enabling domain-wide delegation, you need to impersonate the service account as you.

  • In python you can do it by specifying credentials = credentials.create_delegated(user_email) when instantiating the service object.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.