Nazar Abubaker
Nazar Abubaker

Reputation: 505

Error 403 on Google Sheets API

The URL

https://sheets.googleapis.com/v4/spreadsheets/[ID_OF_SPREADSHEET]?key=[MY_API_KEY]

What I get

   {
      "error": {
        "code": 403,
        "message": "The caller does not have permission",
        "status": "PERMISSION_DENIED"
      }
    }

At the moment, I have no Key Restriction on my API Key for the sake of testing.

I've had a look at a past question that's been popular but no luck.

Upvotes: 9

Views: 23579

Answers (6)

Bálint Nagy
Bálint Nagy

Reputation: 1

Just share your sheet with the service account (just like to another person) as an author!

Upvotes: 0

Rahul Bavaliya
Rahul Bavaliya

Reputation: 161

i face the same issue

i just go https://console.developers.google.com then library->google sheet->enable and Enabled the Google Sheet API

then i have open google sheet and follow below steps:

  1. Extension->Apps Script
  2. Click on Deploy button and select Manage Deployments or new Deployments
  3. Edit Configuration detail and give authorize rights for add, update, delete, view
  4. Click on Deploy

this is working for me.

Upvotes: 0

Balaji
Balaji

Reputation: 10887

i faced same issue in my electron app

i just did

https://console.developers.google.com/

then

choose library->google sheet->enable 

thats it started working to me

Upvotes: 3

eMad
eMad

Reputation: 1008

I encountered the same problem and it turned out that I was trying to write to the sheet by using readonly scope

SCOPE_READ = ['https://www.googleapis.com/auth/spreadsheets.readonly']

Actually I need Read+Write scope (permissions) to write to the spreadsheet:

SCOPE_WRITE = ['https://www.googleapis.com/auth/spreadsheets']

When you will be prompted by Google Accounts prompt for authorizing the app to access the sheets, you can see there what permissions your script has requested. Make sure they are the right ones.

Upvotes: 0

ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17613

This is similar to this 403 error in Drive API wherein you have insufficient permission. By that, you need authentication and authorization using OAuth. There are quickstart guides which has implementation in JavaScript, Python,etc.

To prove this, go to auth playground and get the permissions for 'Google Sheets API v4'. Follow the steps and place your URI request in Step 3. You shouldn't have problems performing operations after that.

Check this SO thread for additional reference on how to use OAuth Playground.

Upvotes: 2

JonasJR
JonasJR

Reputation: 76

Not a lot to go on here, have you checked that the user that you are authenticated as must have permission to the file. So check in the File->Share->Advanced and check if the Sharing settings have the email that you are logged in to in your application.

Upvotes: 0

Related Questions