我正在尝试使用 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
如果有人能指出我正确的方向,那就太好了