taers232c / GAMADV-XTD3

Command line tool to manage Google Workspace
723 stars 86 forks source link

Questions about profile photos #322

Closed DanielMalmgren closed 1 year ago

DanielMalmgren commented 1 year ago

Hi. I have a couple of questions about gam user get profilephoto, I hope it's ok to ask them here:

  1. What is the data returned from the command? I first thought it might be the photo base64 encoded, but it seems not. I've tried getting anything useful out of it but failed. I need the photo in a variable so I've resorted to letting gam save the photo and then loading it back in which works but seems like a bit of a cludge.
  2. Is there any way to get the photo in higher resolution? The photos I see on the Google profile is much higher resolution than the ones returned using gam
  3. Is there any way of knowing withoug analyzing the contents what the image format is? It names all of them .jpg but most seems to actually be png files...
  4. Is there any way of knowing if this is a real image that the user uploaded or one of those generated letter-dummy-images? The latter isn't very useful, but I see no way of differentiate them from the real ones.
taers232c commented 1 year ago

Daniel,

Send me a Meet/Zoom invitation.

Ross

On Fri, Jan 13, 2023 at 7:15 AM Daniel Malmgren @.***> wrote:

Hi. I have a couple of questions about gam user get profilephoto, I hope it's ok to ask them here:

  1. What is the data returned from the command? I first thought it might be the photo base64 encoded, but it seems not. I've tried getting anything useful out of it but failed. I need the photo in a variable so I've resorted to letting gam save the photo and then loading it back in which works but seems like a bit of a cludge.
  2. Is there any way to get the photo in higher resolution? The photos I see on the Google profile is much higher resolution than the ones returned using gam
  3. Is there any way of knowing withoug analyzing the contents what the image format is? It names all of them .jpg but most seems to actually be png files...
  4. Is there any way of knowing if this is a real image that the user uploaded or one of those generated letter-dummy-images? The latter isn't very useful, but I see no way of differentiate them from the real ones.

— Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/322, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYL7CPJCBVDLRRROMKTTWSFWRLANCNFSM6AAAAAAT2QRFLI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Ross Scroggs @.***

taers232c commented 1 year ago

1) Here is the API documentation about the photo: https://developers.google.com/people/api/rest/v1/people#Person.Photo The data is base64 encoded

2) In 6.30.13 I added the option size <Integer> to get profilephoto; it sets sz= as described above

3) The API documentation show a file extension in the example, none of the urls i see have that

4) The API describes a field default; it isn't being returned

DanielMalmgren commented 1 year ago

Hi. Thanks for the quick answer! Responses below:

1 and 3: That is strange, for the ones I checked I didn't get valid base64. I wonder if it could be related to the image type in some way... I'll do some more tests and get back to you with results!

2: Thanks, I missed that one! Where do I find up to date documentation of all arguments?'

4: I see. And I guess you can't return it without breaking backwards compatibility... Would it be possible to add an argument (something like "nodefault" or "onlyreal") that made the command return nothing at all if it is a default photo?

taers232c commented 1 year ago

2: https://developers.google.com/people/api/rest/v1/people

4: I can do this but the API isn't returning the default field; try this on a few users gam user user@domain.com show peopleprofile fields photo

I'm in California (PST) and can do Meet/Zoom if you'd like.

DanielMalmgren commented 1 year ago

Well, I'm kinda dodging the meeting option since I'm in Sweden which is 9 hours time zone away. And I think we soon have the answers anyway :-)

  1. Solved the mystery now. [System.Convert]::FromBase64String() says the value returned isn't base64 and that's because it expects standard base64. It seems the value returned is "URL- and filename-safe standard", which means "+" and "/" are replaced by "-" and "". So if I first do a .replace("-", "+").replace("", "/") on the value I can then decode it as normal base64.
  2. I was rather thinking if there's a documentation of the arguments to the gam command?
  3. It turns out after some more testing that the image returned simply has the same format that the user in question uploaded it in, so if the user uploaded a jpg you get a jpg back. Also the default images are all png.
  4. It seems the default field is only returned if it in fact is a default image. This is what I get back from that command:

For an user that has uploaded a photo:

User: <obfuscated>, People Profile: people/109273370044977978275
  photos:
    metadata:
      primary: True
      source:
        id: 109273370044977978275
        type: PROFILE
      url: https://lh3.googleusercontent.com/a/AEdFTp60zZByCDFnPqEg-k9u5TzB584ffQ6g81SZkGE5PQ=s100
  resourceName: people/109273370044977978275

and for an user that has no photo uploaded:

User: <obfuscated>, People Profile: people/110674097844672917887
  photos:
    default: True
      metadata:
        primary: True
        source:
          id: 110674097844672917887
          type: PROFILE
      url: https://lh3.googleusercontent.com/a/AEdFTp4RqnlgkwVf8J6V8qGpMhPIbxhSGsXFllzT_qeq=s100
  resourceName: people/110674097844672917887
taers232c commented 1 year ago

Daniel,

I can Meet now if you're available.

Ross

On Mon, Jan 16, 2023 at 10:15 PM Daniel Malmgren @.***> wrote:

Well, I'm kinda dodging the meeting option since I'm in Sweden which is 9 hours time zone away. And I think we soon have the answers anyway :-)

  1. Solved the mystery now. [System.Convert]::FromBase64String() says the value returned isn't base64 and that's because it expects standard base64. It seems the value returned is "URL- and filename-safe standard", which means "+" and "/" are replaced by "-" and "". So if I first do a .replace("-", "+").replace("", "/") on the value I can then decode it as normal base64.
  2. I was rather thinking if there's a documentation of the arguments to the gam command?
  3. It turns out after some more testing that the image returned simply has the same format that the user in question uploaded it in, so if the user uploaded a jpg you get a jpg back. Also the default images are all png.
  4. It seems the default field is only returned if it in fact is a default image. This is what I get back from that command: For an user that has uploaded a photo: User: , People Profile: people/109273370044977978275 photos: metadata: primary: True source: id: 109273370044977978275 type: PROFILE url: https://lh3.googleusercontent.com/a/AEdFTp60zZByCDFnPqEg-k9u5TzB584ffQ6g81SZkGE5PQ=s100 resourceName: people/109273370044977978275

and for an user that has no photo uploaded: User: , People Profile: people/110674097844672917887 photos: default: True metadata: primary: True source: id: 110674097844672917887 type: PROFILE url: https://lh3.googleusercontent.com/a/AEdFTp4RqnlgkwVf8J6V8qGpMhPIbxhSGsXFllzT_qeq=s100 resourceName: people/110674097844672917887

— Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/322#issuecomment-1384884953, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYL72YSTAXUDNN7POFRDWSY2GPANCNFSM6AAAAAAT2QRFLI . You are receiving this because you commented.Message ID: @.***>

-- Ross Scroggs @.***

taers232c commented 1 year ago

6.30.16

Added option nodefault to gam <UserTypeEntity> get profilephoto that causes GAM to display an

error message and set the return code to 50 if the user has a default profile photo.

On Tue, Jan 17, 2023 at 7:30 AM Ross Scroggs @.***> wrote:

Daniel,

I can Meet now if you're available.

Ross

On Mon, Jan 16, 2023 at 10:15 PM Daniel Malmgren @.***> wrote:

Well, I'm kinda dodging the meeting option since I'm in Sweden which is 9 hours time zone away. And I think we soon have the answers anyway :-)

  1. Solved the mystery now. [System.Convert]::FromBase64String() says the value returned isn't base64 and that's because it expects standard base64. It seems the value returned is "URL- and filename-safe standard", which means "+" and "/" are replaced by "-" and "". So if I first do a .replace("-", "+").replace("", "/") on the value I can then decode it as normal base64.
  2. I was rather thinking if there's a documentation of the arguments to the gam command?
  3. It turns out after some more testing that the image returned simply has the same format that the user in question uploaded it in, so if the user uploaded a jpg you get a jpg back. Also the default images are all png.
  4. It seems the default field is only returned if it in fact is a default image. This is what I get back from that command: For an user that has uploaded a photo: User: , People Profile: people/109273370044977978275 photos: metadata: primary: True source: id: 109273370044977978275 type: PROFILE url: https://lh3.googleusercontent.com/a/AEdFTp60zZByCDFnPqEg-k9u5TzB584ffQ6g81SZkGE5PQ=s100 resourceName: people/109273370044977978275

and for an user that has no photo uploaded: User: , People Profile: people/110674097844672917887 photos: default: True metadata: primary: True source: id: 110674097844672917887 type: PROFILE url: https://lh3.googleusercontent.com/a/AEdFTp4RqnlgkwVf8J6V8qGpMhPIbxhSGsXFllzT_qeq=s100 resourceName: people/110674097844672917887

— Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/322#issuecomment-1384884953, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYL72YSTAXUDNN7POFRDWSY2GPANCNFSM6AAAAAAT2QRFLI . You are receiving this because you commented.Message ID: @.***>

-- Ross Scroggs @.***

-- Ross Scroggs @.***

DanielMalmgren commented 1 year ago

Hi. I think my working hours are actually only while you're sleeping :-D

The nodefault option works like a charm, thanks a lot!

However... The size option does nothing at all for me, even when tacking "size 500" on the command all I get are 100x100 pixel images. Is it me doing anything wrong? I also tried combining size 500 with returnurlonly and the returned urls end with s100, guess that's 100 pixels? When I browse the url and change 100 to 500 I get the image in 500x500 pixels.

taers232c commented 1 year ago

Daniel,

API documentation bug, I'll update code.

Ross

Ross Scroggs @.***

On Jan 18, 2023, at 12:13 AM, Daniel Malmgren @.***> wrote:

Hi. I think my working hours are actually only while you're sleeping :-D

The nodefault option works like a charm, thanks a lot!

However... The size option does nothing at all for me, even when tacking "size 500" on the command all I get are 100x100 pixel images. Is it me doing anything wrong? I also tried combining nodefault with returnurlonly and the returned urls end with s100, guess that's 100 pixels? When I browse the url and change 100 to 500 I get the image in 500x500 pixels.

— Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/322#issuecomment-1386649010, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYL42KEZYIGSMZ5YNRB3WS6QZTANCNFSM6AAAAAAT2QRFLI. You are receiving this because you commented.

taers232c commented 1 year ago

6.30.17 - size should work API said to append ;sz= to URL, it's really =s

Ross

On Wed, Jan 18, 2023 at 6:44 AM Ross Scroggs @.***> wrote:

Daniel,

API documentation bug, I'll update code.

Ross

Ross Scroggs @.***

On Jan 18, 2023, at 12:13 AM, Daniel Malmgren @.***> wrote:

Hi. I think my working hours are actually only while you're sleeping :-D

The nodefault option works like a charm, thanks a lot!

However... The size option does nothing at all for me, even when tacking "size 500" on the command all I get are 100x100 pixel images. Is it me doing anything wrong? I also tried combining nodefault with returnurlonly and the returned urls end with s100, guess that's 100 pixels? When I browse the url and change 100 to 500 I get the image in 500x500 pixels.

— Reply to this email directly, view it on GitHub https://github.com/taers232c/GAMADV-XTD3/issues/322#issuecomment-1386649010, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCTYL42KEZYIGSMZ5YNRB3WS6QZTANCNFSM6AAAAAAT2QRFLI . You are receiving this because you commented.Message ID: @.***>

-- Ross Scroggs @.***

DanielMalmgren commented 1 year ago

Aha, that explains it! Let's hope they don't change the API to matche the documentation now :-)

The fix works like a charm! Thank you very much for your hard work on this!