Google apps script 将Google应用程序配置文件API与应用程序脚本一起使用

Google apps script 将Google应用程序配置文件API与应用程序脚本一起使用,google-apps-script,Google Apps Script,我正在尝试使用Google Apps Profiles Data API检索我域中Google Apps用户的配置文件信息。这里是我到目前为止尝试过的代码,但返回的代码403出现了错误Request failed。服务器响应:不支持版本1.0。(第7行,文件“配置文件”) 注: 我的帐户在谷歌应用程序中具有超级管理员权限 我正在谷歌应用企业版上尝试这段代码 参考资料: 如果有人能给我指出正确的方向那就太好了这是修改过的代码,它需要一个带有请求URL的版本参数。现在代码运行良好 functi

我正在尝试使用Google Apps Profiles Data API检索我域中Google Apps用户的配置文件信息。这里是我到目前为止尝试过的代码,但返回的代码403出现了错误
Request failed。服务器响应:不支持版本1.0。(第7行,文件“配置文件”)

注:

  • 我的帐户在谷歌应用程序中具有超级管理员权限
  • 我正在谷歌应用企业版上尝试这段代码
参考资料:


如果有人能给我指出正确的方向那就太好了

这是修改过的代码,它需要一个带有请求URL的版本参数。现在代码运行良好

function getAllProfiles() {
  var scope = 'https://www.google.com/m8/feeds/profiles';
  var fetchArgs = googleOAuth_('Profile', scope);
  fetchArgs.method = 'GET';
  var domain = UserManager.getDomain();
  var url = scope+'/domain/'+domain+'/full?v=3';
  var rawData = UrlFetchApp.fetch(url, fetchArgs).getContentText();
  Logger.log(rawData);
}

//google oAuth
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"};
}

你看到了吗?“我成功地尝试了它。”Sergeinsas感谢您指向该链接。当我向请求URL添加了一个版本参数v=3时,我的代码开始工作
function getAllProfiles() {
  var scope = 'https://www.google.com/m8/feeds/profiles';
  var fetchArgs = googleOAuth_('Profile', scope);
  fetchArgs.method = 'GET';
  var domain = UserManager.getDomain();
  var url = scope+'/domain/'+domain+'/full?v=3';
  var rawData = UrlFetchApp.fetch(url, fetchArgs).getContentText();
  Logger.log(rawData);
}

//google oAuth
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"};
}