API help on expanding related image data

bobgottbobgott Registered Users Posts: 3 Big grins
Hi Folks,
I'm trying to do some analysis via python and the SmugMug API. My scripts are running but as I do need the date/time that a photo was created that requires me to utilize the ImageMetadata. Right now I'm making 1 call to download all image data for an album (not the images themselves) then I need to make another call per image to get the DateTimeCreated from ImageMetadata. Obviously this is S.L.O.W.

Utilizing the API _expand function, I've tested the following url against the Live API browser and it seems to work:
... api.smugmug.com/api/v2/album/zc5wwB!images?_expand=ImageMetadata

but when I use the same url in my python program (via GET method) I get a 401 respnse error:
response: 401
Message: oauth_problem=signature_invalid
debug_sbs=GET&https%3A%2F%2Fapi.smugmug.com%2Fapi%2Fv2%2Falbum%2FXnch6w%21images&_expand%3DImageMetadata%26max_album_count%3D100%26oauth_consumer_key%3Dxxxxxxxx%26oauth_nonce%3Dxxxxx478fab46dxxxxxxx%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1566203136%26oauth_token%3Dr85SfV25sJ2NF9xxxxx%26oauth_version%3D1.0%26start%3D1

Can you let me know what I am doing wrong with the _expand function?

Comments

  • Jeffrey FriedlJeffrey Friedl Registered Users Posts: 32 Big grins

    I'm not sure how this would result in an invalid signature, but based upon the "debug_sbs" reported, you're putting "&" before _expand instead of "?"

  • bobgottbobgott Registered Users Posts: 3 Big grins
    I checked my code and in fact the "?" is there on the way up .. for some reason debug_sbs is replacing it with an "&". Don't know why. Then again, I'm getting an invalid signature .. which doesn't occur when I omit the expand.
  • bobgottbobgott Registered Users Posts: 3 Big grins
    Jeffrey, well I figured out the problem. Your observation was a symptom, not the cause. As it turned out I mistakingly put the query part of the expression "?_expand=ImageMetadata" attached to the end of url. With OAuth, the query part must be in the parameters (params - dict) and not url.

    response = self.request('GET', url=url, params=params, headers={'Accept': 'application/json'})
Sign In or Register to comment.