0

Following is function call and function which helps in oAuth1 in Google Apps Script for Authorization from google Docs but as oAuth1 is getting discontinue from 20 April 15, replacement code for oAuth2 is hard to find. Please help me for same.

var auth = googleOAuth_('docs',scope);

function googleOAuth_(name,scope)
{
var oAuthConfig = UrlFetchApp.addOAuthService(name);
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig.setConsumerKey("anonymous");
oAuthConfig.setConsumerSecret("anonymous");
return {oAuthServiceName:name, oAuthUseToken:"always"};
}

1 Answers1

1

I would recommend you look at the Drive advanced service. It has all the granular functionality of the REST api interface but with the tight integration of a Apps Script service.

https://developers.google.com/apps-script/advanced/drive

There are two cases where you may need to handle your own access to the Drive sdk: when using service account tokens or accessing the appfolder. In either case you can use a library like: https://github.com/googlesamples/apps-script-oauth2

The readme on that library is quite through.

Spencer Easton
  • 5,642
  • 1
  • 16
  • 25