title: Retrieve photo from Google Apps Profile API
body: <p>I am trying to retrieve Google Apps Profile API photo using Google Apps Profile API but It keeps on prompting to authorize the request even after authorizing it.
  Here is the code which I have tried so far.</p>
  
  <pre><code>function getPhoto(userName){
    userName = 'user@myDomain.com'; //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"};
  }
  </code></pre>
  
  <p>Refernces : </p>
  
  <ul>
  <li><a href="https://developers.google.com/google-apps/profiles/#photo_management" rel="nofollow">https://developers.google.com/google-apps/profiles/#photo_management</a></li>
  <li><a href="https://developers.google.com/google-apps/profiles/auth" rel="nofollow">https://developers.google.com/google-apps/profiles/auth</a></li>
  </ul>
  
  <p>Note : I have super administrator access to the domain I am trying</p>