alexis-mignon / python-flickr-api

A python implementation of the Flickr API
BSD 3-Clause "New" or "Revised" License
367 stars 108 forks source link

Can't seem to fetch my own private photos #125

Closed smontanaro closed 2 years ago

smontanaro commented 2 years ago

Given this code:

import flickr_api

# these are the key and secret for my account, associated with skip.montanaro@gmail.com
api_key = 'blah blah blah'
api_secret = 'blah blah blah'

flickr_api.set_keys(api_key=api_key, api_secret=api_secret)

# this correctly returns me, user "smontanaro"
user = flickr_api.Person.findByEmail("skip.montanaro@gmail.com")

photos = user.getPhotos(privacy_filter=5)
for photo in photos:
    print(photo.id, photo.ispublic)

when executed, photo.ispublic prints as True for all returned photos. Given the value passed for privacy_filter they all be False?

smontanaro commented 2 years ago

My problem seems to be that I'm not really authenticating. I stumbled on an Authentication section in the wiki (not sure why I didn't see that before), but the prescription there doesn't work. I'm unable to create an AuthHandler instance.


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_77955/3000982355.py in <module>
----> 1 a = flickr_api.api.auth.AuthHandler()

~/miniconda3/envs/python39/lib/python3.9/site-packages/flickr_api/auth.py in __init__(self, key, secret, callback, access_token_key, access_token_secret, request_token_key, request_token_secret)
     73             'oauth_version': "1.0",
     74             'oauth_callback': callback,
---> 75             'oauth_nonce': oauth2.generate_nonce(),
     76             'oauth_consumer_key': self.key
     77         }

AttributeError: module 'oauth2' has no attribute 'generate_nonce'

It seems this code is not up-to-date with the oauth2 module. Maybe the example is missing something?

smontanaro commented 2 years ago

Stupidity on my part, I was pasting the auth url instead of the redirect url. :dodo: