Using a Google Apps Script I am generating a list of users and their photo thumbnails for a work intranet. This intranet requires logging into Google using Oauth.
The thumbnail URLs look something like:
https://lh3.google.com/ao/AHP4FtlN1wzP_pjUvk0MEP-2tSZumfJi9eMJmCvi0mK8QDvuUSyU-kzXARP_oCrxjC6ugchgVUA=s288-c
This on it’s own will not work and yields the following “generic” silhouette placeholder:
If I add the following “user” part to the url: /u/1
https://lh3.google.com/u/1/ao/AHP4FtlN1wzP_pjUvk0MEP-2tSZumfJi9eMJmCvi0mK8QDvuUSyU-kzXARP_oCrxjC6ugchgVUA=s288-c
The image works and I get the correct thumbnail at the requested size (288×288 pixels )
I understand that the 1 in /u/1 denotes the order that I’ve logged into my Google account. 1 means that it’s the second account that I’ve logged into, 0 being the first.
I’ve also found that for some Google URLs I can replace the number with the account I’m wanting to use to access the resource.
e.g.
Google Drive thumbnails:
https://drive.google.com/[email protected]&sz=w175&id=ALV-UjXcpIrWPSs-S6EKh2joeQh_C18zIGCcCqBt9arhmKbF1_kaZZp
Google Calendar links:
https://calendar.google.com/calendar/b/[email protected]/r/eventedit/1234567890
So, my question is. How can I determine the user number that my email address maps to?
I am using PHP with GoogleOAuth to login with the following code/scopes:
$this->client = new GoogleClient();
$this->client->setAuthConfig($oauthCredentialsFile);
$this->client->setRedirectUri($redirectUri);
$this->client->addScope('https://www.googleapis.com/auth/userinfo.profile');
$this->client->addScope('https://www.googleapis.com/auth/userinfo.email');
I’ve checked the values of the OAuth values and $me = $oauth2Service->userinfo_v2_me->get();
, but nothing helps.
Is there anything I can add to determine which user (/u/1) I am currently?
I know that for most users of the intranet they will only be logged into one Google Account and I can therefore just use /u/0, but this seems clunky.
I’ve also found that I can download the thumbnail photo in Google Apps Script, but this size is limited to 96×96 pixels and I could not find a way of getting a larger size.
Thanks!