Album API endpoint - retrieving Unlisted albums

robrobrobrob USAPosts: 2Registered Users Beginner grinner
I'm calling "api.smugmug.com/api/v2/user/XXXXXX!albums", and I'm getting a result that has albums that are public. How can I also get Unlisted albums?

Comments

  • gibertigiberti SmugMug Sorcerer Posts: 17Registered Users Big grins

    You'll have to make an authenticated call using OAuth. This means passing an appropriate Authorization header. There are a lot of guides that can walk you through this process and there are helper libraries available for pretty much every modern language and request library. Note that we use OAuth 1.0a, which is very different than OAuth 2.0, so make sure you are working with the correct version.

    APIv2 and OAuth are your friend! Having issues? Just ask, I can help!
  • robrobrobrob USAPosts: 2Registered Users Beginner grinner
    edited August 5, 2018
    Here's what I'm doing in python 2.7 (key/secret/token set up previously):

    from rauth import OAuth1Service
    from rauth import OAuth1Session
    import json

    service = OAuth1Service(
    name='smugmug-list',
    consumer_key=key,
    consumer_secret=secret,
    ...
    base_url='htt ps://api.smugmug.com/api/v2')

    session = OAuth1Session(
    service.consumer_key,
    service.consumer_secret,
    access_token=at,
    access_token_secret=ats)

    albums=json.loads(session.get(
    "htt ps://api.smugmug.com/api/v2/user/XXXXXX!albums",
    headers={'Accept': 'application/json'}).text).get('Response').get('Album')




    How can I tell if the call is authenticated? I went through the whole thing about getting the numeric code and entering it on the page in the browser to get the token.

    (Edit: url's above edited to allow forum to let me "post links")
  • mardymardy RussiaPosts: 10Registered Users Big grins
    Your code looks correct. To make sure that you are properly authenticated, try calling the api.smugmug.com/api/v2!authuser endpoint instead.

    PhotoTeleport: open source, multi platform photo uploader.

Sign In or Register to comment.