Any way to download the user photos that the thumbnailPhotoUrl attribute links to in Print Users?

1,437 views
Skip to first unread message

Nate Ferrell

unread,
Jul 29, 2016, 3:49:48 PM7/29/16
to Google Apps Manager
Hey guys,

I'm trying to download all of our Org's user profile photos to convert them to Base64 for our Employee Directory... I can pull the URL to the thumbnail, but I'm not able to download some of the photos due to receiving a 403 Forbidden response. I know it's due to how I'm downloading them currently (Invoke-WebRequest "<url>" in Powershell) and the fact that the session does not have myself logged in, as I can replicate it when pulling up the URL in browser in my normal logged in session but it gets a 403 when going from incognito mode.

Any way to just use GAM to download those photos, or does anyone know what credentials would be needed to pull those using my method (assuming ASP + email maybe?)?


Thanks a MILLION in advance!

Nate Ferrell

unread,
Jul 29, 2016, 4:04:59 PM7/29/16
to Google Apps Manager
If possible, any way to return the values advised by the Users.photos portion in Directory API would be perfect, since I really just need the base64 and don't need the actual jpg file:

Ross Scroggs

unread,
Jul 29, 2016, 6:12:59 PM7/29/16
to google-ap...@googlegroups.com
Nate,

gam user f...@domain.com get photo
will download foo's photo into your current working directory as f...@domain.com.jpg
You could say: gam all users get photo
For parallelism, say: gam print users | gam csv - gam user ~primaryEmail get photo

Ross

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/7782ec0e-c5f3-46d1-89bc-1ac961258a2c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Nate Ferrell

unread,
Jul 29, 2016, 6:24:16 PM7/29/16
to google-ap...@googlegroups.com
Ross, you are the man. I can't thank you enough!

Thank you for your time,
Nate Ferrell
Systems Engineer | PennyMac
O: 817.494.0332 | x5120




--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Manager" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/LtdIML8yGoo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

Nate Ferrell

unread,
Jul 29, 2016, 6:27:42 PM7/29/16
to google-ap...@googlegroups.com
Considering the User.Photos API does return the Base64 for the photo though, would there be any GAM call currently that returns that info? That would save from the whole downloading of the photo portion if possible! I have the API calls down already, but dealing with the Refresh tokens isn't something that I can automate as faithfully as I can with GAM at the moment

Thank you for your time,
Nate Ferrell
Systems Engineer | PennyMac
O: 817.494.0332 | x5120




Jay Lee

unread,
Jul 29, 2016, 6:33:55 PM7/29/16
to google-ap...@googlegroups.com

The APIs actually return web-safe base64 which is not the same thing. It's relatively painless to base74 encode a file via PowerShell. A quick search turns up:

http://powershellscripts.blogspot.com/2007/02/base64-encode-file.html

Jay



For more options, visit https://groups.google.com/d/optout.
--

Jay

Nate Ferrell

unread,
Jul 29, 2016, 6:45:01 PM7/29/16
to google-ap...@googlegroups.com
yup yup, I have the conversion from Web Safe to normal Base64 working for that API call great, but maintaining a working token has been a pain for some reason and GAM has always been rock solid for automation tasks

In the command that Ross provided, I can see the Web Safe Base64 being kicked back in the text response. If there was a way to kick back just that and negate the jpg download, that'd be sweeeeeet

Thank you for your time,
Nate Ferrell
Systems Engineer | PennyMac
O: 817.494.0332 | x5120




Paolo Chua

unread,
Aug 10, 2022, 6:03:57 AM8/10/22
to GAM for Google Workspace
Hello, I tried this and it worked great; is there a way to download a higher resolution photo? I need it to print IDs for our school

The content of this email is confidential and intended for the recipient specified in message only. Any dissemination or use of this information by a person other than the intended recipient is unauthorized and may be illegal. If you are not the intended recipient of this email, please immediately notify the sender and delete this message. Academia de Lipa (ADL) accepts no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided. Any view or opinion expressed in this email are solely those of the author and do not necessarily represent those of ADL. The integrity and security of this message cannot be guaranteed; ADL accepts no liability for any damage caused by any virus transmitted by this email.
Reply all
Reply to author
Forward
0 new messages