我想在Apps脚本中创建一个可以获取我的谷歌纵横位置历史记录的应用程序。出于某种原因,即使提供了OAuth工作所需的所有URI和令牌,我总是会在触发“UrlFetchApp”的行上遇到“意外错误”。什么是让Latitude API在Apps脚本中运行的正确OAuth配置?
这是代码:
function latitude(){
var oAuthConfig = UrlFetchApp.addOAuthService("latitude");
oAuthConfig.setConsumerKey(consumerKey);
oAuthConfig.setConsumerSecret(consumerSecret);
oAuthConfig.setAuthorizationUrl("https://accounts.google.com/o/oauth2/auth");
oAuthConfig.setAccessTokenUrl("https://accounts.google.com/o/oauth2/auth");
UrlFetchApp.addOAuthService(oAuthConfig);
var response = UrlFetchApp.getRequest("https://www.googleapis.com/latitude/v1/currentLocation");
Logger.log(response);
}