~robru/gwibber/friends

« back to all changes in this revision

Viewing changes to gwibber/gwibber/protocols/flickr.py

  • Committer: Barry Warsaw
  • Date: 2012-10-10 14:34:35 UTC
  • mfrom: (1448.2.1 robru)
  • Revision ID: barry@python.org-20121010143435-bbm9izk63mjg967j
MergeĀ lp:~robru/gwibber/locked-login-refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import logging
23
23
 
24
24
from gwibber.errors import AuthorizationError
25
 
from gwibber.utils.authentication import Authentication
26
25
from gwibber.utils.base import Base, feature
27
26
from gwibber.utils.download import get_json
28
27
from gwibber.utils.time import iso8601utc, parsetime
59
58
                return None
60
59
        return self._account.user_id
61
60
 
62
 
    def _locked_login(self, old_token):
63
 
        if old_token is None:
64
 
            log.debug('Logging into Flickr')
65
 
        else:
66
 
            log.debug('Re-authenticating to Flickr')
67
 
        result = Authentication(self._account).login()
68
 
        if result is None:
69
 
            log.error('No Flickr authentication results received')
70
 
        elif 'AccessToken' in result:
71
 
            self._account.user_name = result.get('username')
72
 
            self._account.user_id = result.get('user_nsid')
73
 
            self._account.access_token = result.get('AccessToken')
74
 
            self._account.secret_token = result.get('TokenSecret')
75
 
            log.debug('Flickr AccessToken received')
76
 
        else:
77
 
            log.error('No AccessToken in Flickr session: {!r}'.format(result))
 
61
    def _whoami(self, authdata):
 
62
        """Identify the authenticating user."""
 
63
        self._account.secret_token = authdata.get('TokenSecret')
 
64
        self._account.user_id = authdata.get('user_nsid')
 
65
        self._account.user_name = authdata.get('username')
78
66
 
79
67
# http://www.flickr.com/services/api/flickr.photos.getContactsPublicPhotos.html
80
68
    @feature