1

I'm using Apps Script heavily for maintaining our Google Apps for Business account and now with the ContentService and HtmlService we're expanding its reach into some functions accessible directly from within the corporate intranet.

Is it possible using the Google Domain or Users API exposed by Apps Script to retrieve a users profile image. I can do so using the python API but don't want to introduce a round-trip to an AppEngine or other hosted service to achieve the same end.

Possible?

JSDBroughton
  • 3,966
  • 4
  • 32
  • 52

1 Answers1

0

It is not possible using Apps Script alone. However, Apps Script along with the User Profiles API it is in theory possible. ( https://developers.google.com/google-apps/profiles/#retrieving_photo ).

To marry the two, you can make use of the OAuth Service listed in the notable libraries page ( https://developers.google.com/apps-script/notable-script-libraries )

Srik
  • 7,907
  • 2
  • 20
  • 29
  • having tried my best to follow the OAuth Service library page, the first run using in precis `var options = OAuthApp.getAuth('profiles','https://www.google.com/m8/feeds/photos/');` `var response = UrlFetchApp.fetch("https://www.google.com/m8/feeds/photos/profile/{domain}/{user}?alt=json", options);` prompts for authorisation which fills one with promise, however nothing happens after that has been done. On second run a 403 error is displayed claiming Version 1.0 is not supported. Presumeably that's OAuth1.0? Or have I got the wrong end of the stick. – JSDBroughton Jul 14 '12 at 15:17
  • You're right. You can only do OAuth 1.0 with Apps Scripts. I'm not sure what is the precise problem that you're facing, but you could try having a look at http://stackoverflow.com/questions/11063749/how-do-i-get-an-access-token-using-urlfetchapp-with-gas for some sample code that does this 'marriage' of Apps Scripts and Google Data API – Srik Jul 14 '12 at 16:48
  • Version 1 not supported, meaning Contacts API version 1 not supported. Your OAuth request and authorization worked. Your request to the API used the wrong version. – mzimmerman Jul 15 '12 at 00:59
  • @mzimmerman so ill need a different fetch url and/or scope or is this a futile exercise? – JSDBroughton Jul 15 '12 at 09:44
  • Yes, specify v=3.0 as a query parameter. – Peter Jul 19 '12 at 10:48