Trouble Implementing OAuth in Google Apps Script (

2019-08-12 08:48发布

问题:

I am trying to run the sample Google Apps Script Service Account OAuth example taken from here: https://github.com/googlesamples/apps-script-oauth2/blob/master/samples/GoogleServiceAccount.gs and keep getting a server timed-out error. I copied the exact code and just substituted in the private key, client email, and a user email. The example code looks to be current as there was an update to it on July 30th.

I have authorized https://www.googleapis.com/drive/v2/files through the admin console as well as https://accounts.google.com/o/oauth2/token and have listed these as scopes in the admin settings (and domain-wide delegation is enabled). I am using an admin account to run the script.

I keep getting the ubiquitious "Server Timed Out" error and nothing shows up in the Execution Logs.

What might be the problem? Any help would be appreciated. Thanks in advance.

回答1:

Thanks, Gerardo, for pointing me in the right direction. It turned out that our organization manages permissions for the Google Developer's Console by Organizations (in the Google Admin console). Somehow a few accounts, including mine, were kicked out of the Organization that had permissions to access the Developer's Console. After adding myself back in, the sample worked without problems.