Извличане на снимка от API на Google Apps Profile

Опитвам се да извлека снимка на API на Google Apps Profile с помощта на API на Google Apps Profile, но той продължава да подканва да упълномощи заявката дори след като я упълномощи. Ето кода, който съм пробвал досега.

function getPhoto(userName){
  userName = '[email protected]'; //will be replaced by actual username
  var scope = 'https://www.google.com/m8/feeds/profiles';
  var fetchArgs = googleOAuth_('Profile', scope);
  fetchArgs.method = 'GET';
  var domain = UserManager.getDomain();
  var url = 'https://www.google.com/m8/feeds/photos/profile/'+domain+'/'+userName+'?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"};
}

препратки:

Забележка: Имам супер администраторски достъп до домейна, който опитвам


person Waqar Ahmad    schedule 04.04.2013    source източник


Отговори (2)


Можете да опитате с

var scope = 'https://www.google.com/m8/feeds/';

да упълномощавам.

person Suhail Ansari    schedule 16.04.2013

Можете да разгледате тази библиотека. Позволява ви да получите снимката на потребителския профил като петно ​​без проблем: https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/profiles-services

person Romain Vialard    schedule 14.04.2013