~robru/gwibber/get_tokens

« back to all changes in this revision

Viewing changes to gwibber/gwibber/utils/base.py

  • Committer: Robert Bruce Park
  • Date: 2012-09-25 18:57:09 UTC
  • Revision ID: robert.park@canonical.com-20120925185709-t0w9osa66yeqloig
Promote FourSquare._get_access_token to Base._get_access_token.

It's generic enough for other protocols to benefit, too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
202
202
                row[IDS_IDX] = row[IDS_IDX] + args[IDS_IDX]
203
203
            return key in _seen_messages
204
204
 
 
205
    def _get_access_token(self):
 
206
        """Return an access token, logging in if necessary."""
 
207
        if self._account.access_token is None:
 
208
            if not self._login():
 
209
                log.error(
 
210
                    'No {} authentication results received.'.format(
 
211
                        self.__class__.__name__))
 
212
                return None
 
213
        return self._account.access_token
 
214
 
205
215
    def _login(self):
206
216
        """Prevent redundant login attempts."""
207
217
        # The first time the user logs in, we expect old_token to be None.