0

I've created a spreadsheet, which I managed to successfully update with some data using the google api library and by creating a service accounts credentials from Google console -> Api & Services -> Credentials.

My problem is to try to restrict the access of the spreadsheet file. If don't allow to be publicly available for everyone with Editor roles, it will not work. I m getting this message:

{ "error": { "code": 403, "message": "The caller does not have permission", "errors": [ { "message": "The caller does not have permission", "domain": "global", "reason": "forbidden" } ], "status": "PERMISSION_DENIED" } } 

If I allow for everyone to access my spreadsheet, like in the image below , it will work . enter image description here

I am also running my script, which updates the spreadsheet via a cronjob. Also this is the code where I do the auth part and I'm using the data from my Service Contract:

 $client = new Google_Client(); $client->setApplicationName('Google Sheets and PHP'); $configuration = '{ "type": "'.$apiConfig['keyFile']['type'].'", "project_id": "'.$apiConfig['projectId'].'", "private_key_id": "'.$apiConfig['keyFile']['private_key_id'].'", "private_key": "'.$key.'", "client_email": "'.$apiConfig['keyFile']['client_email'].'", "client_id": "'.$apiConfig['keyFile']['client_id'].'", "auth_uri": "'.$apiConfig['keyFile']['auth_uri'].'", "token_uri": "'.$apiConfig['keyFile']['token_uri'].'", "auth_provider_x509_cert_url": "'.$apiConfig['keyFile']['auth_provider_x509_cert_url'].'", "client_x509_cert_url": "'.$apiConfig['keyFile']['client_x509_cert_url'].'" }'; $client->setAuthConfig(json_decode($configuration, true)); $client->setScopes([Google_Service_Sheets::SPREADSHEETS]); $client->setAccessType('offline'); return new Google_Service_Sheets($client); 

Does anyone have any clue how can I restrict the access? and still have this work?

Thanks a lot for any suggestions

1 Answer 1

1

Finally I got it work by adding this email address : enter image description here

To the Share with people and groups. See image from my post(question) .

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.