2

I am trying to use gspread to access some sheets at work.

I followed all the steps here -> https://gspread.readthedocs.io/en/latest/oauth2.html

However, I am stuck in this step:

  1. Go to your spreadsheet and share it with a client_email from the step above. Otherwise you’ll get a SpreadsheetNotFound exception when trying to access this spreadsheet with gspread.

Since I'm doing this with my company's Gsuite account, I cannot share my sheet with "external domain".

Below is the message that I get when I try to share my sheet with the service account.

Sorry, policy set by the administrators of ******* CO., LTD. prohibits the sharing of items with ****@****-269407.iam.gserviceaccount.com, because it is not a Google account in a compatible whitelisted domain.

I am afraid the security guys will be bothered to whitelist this just for me, so i need to find my way around it.

With R, there is no problem accessing my sheet with the 'googlesheets4' package.

I can simply run sheets_auth() to get a popup window that lets me log in with my Gsuite account.

Is there any way that I can do this with gspread? Seems like there used to be gspread.login('xxxx@xxx.com','password') option before (Which no longer works).

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Indeed, `login()` method, unfortunately, was deprecated by Google API a long time ago. Thanks for the hint on googlesheets4 though, I'll take a look if something similar can be done in gspread. – Burnash Mar 10 '20 at 15:53
  • 2
    @Burnash, FYI googlesheet package in R is deprecated a long time ago. googlesheets4 package still works! I think gargle is the name of the dependant r package that's used for google auth. – Taeyoung Ahn Mar 11 '20 at 16:09
  • Taeyoung Ahn, thanks for the hint. In gspread version 3.5.0 I've implemented an OAuth2 flow similar to what you've described. Could you upgrade gspread and give it a try? Here's the guide: https://gspread.readthedocs.io/en/latest/oauth2.html#for-end-users-using-oauth-client-id – Burnash May 05 '20 at 10:19

0 Answers0