Skip to content

Instantly share code, notes, and snippets.

@soundTricker
Last active October 15, 2017 07:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save soundTricker/5664078 to your computer and use it in GitHub Desktop.
Save soundTricker/5664078 to your computer and use it in GitHub Desktop.
Get Spreadsheet Comments
var apiKey = "Your API KEY";
function myFunction() {
var option = googleOAuth_();
option.method = "get";
//Spreadsheet.getActive().getId()をそのまま使うと、エラーになるので一回DriveのFileにかえてからIDを取得
var res = UrlFetchApp.fetch("https://www.googleapis.com/drive/v2/files/"+ DriveApp.getFileById(SpreadsheetApp.getActive().getId()).getId() +"/comments?key=" + apiKey , option);
var json = JSON.parse(res.getContentText());
Logger.log(json)
}
function googleOAuth_() {
var oAuthConfig = UrlFetchApp.addOAuthService('drive');
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/"+
"OAuthGetRequestToken?scope=https://www.googleapis.com/auth/drive+https://www.googleapis.com/auth/drive.file");
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig.setConsumerKey('anonymous');
oAuthConfig.setConsumerSecret('anonymous');
return {oAuthServiceName:'drive', oAuthUseToken:"always"};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment