【发布时间】:2013-03-29 06:02:47
【问题描述】:
我正在尝试使用 Google Apps Profiles Data API 来检索我的域中 Google Apps 用户的个人资料信息。这是我迄今为止尝试过的代码,但它给出了错误Request failed for returned code 403. Server response: Version 1.0 is not supported. (line 7, file "Profile")
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';
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"};
}
注意:
- 我的帐户在 Google Apps 中具有超级管理员权限
- 我正在使用 Google Apps Enterprise Edition 尝试此代码
参考资料: Google Apps Profile Data API
如果有人能指出正确的方向,那就太好了
【问题讨论】:
-
你见过this post 吗?我尝试成功了。
-
@Sergeinsas 感谢您指向该链接。当我将版本参数 v=3 添加到请求 URL 时,我的代码工作了