Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try and reuse the token cached by flickrapi to not replay the pairing ev... #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@ def fetch(api_key, api_secret):
# create an unauthenticated flickrapi object
flickr=flickrapi.FlickrAPI(api_key, api_secret)

print "Open the following URL in your browser "
print "This Url >>>> %s" % flickr.web_login_url(perms='read')
# Try to reuse token cached by flickrapi
(token, frob) = flickr.get_token_part_one('read')
if not token:

print "When you're ready press ENTER",
raw_input()
# Then redo the authentication scenario
print "Open the following URL in your browser "
print "This Url >>>> %s" % flickr.web_login_url(perms='read')

print "Copy and paste the URL (from theopenphotoproject.org) here: ",
frob_url = raw_input()
print "When you're ready press ENTER",
raw_input()

print "\nThanks!"
print "Copy and paste the URL (from theopenphotoproject.org) here: ",
frob_url = raw_input()

print "Parsing URL for the token...",
match = re.search('frob=([^&]+)', frob_url)
frob = match.group(1)
token = flickr.get_token(frob)
print "OK"
print "\nThanks!"

print "Parsing URL for the token...",
match = re.search('frob=([^&]+)', frob_url)
frob = match.group(1)
token = flickr.get_token(frob)
print "OK"

# create an authenticated flickrapi object
flickr = flickrapi.FlickrAPI(api_key, api_secret, token=token)
Expand Down