~fom-dev/fom/trunk

« back to all changes in this revision

Viewing changes to fom/db.py

  • Committer: Nicholas Tollervey
  • Date: 2011-12-03 13:34:09 UTC
  • mfrom: (154.1.1 add-oauth-calls-899576)
  • Revision ID: ntoll@ntoll.org-20111203133409-hm63r8s3zz6zsh8h
Bumped version number

Show diffs side-by-side

added added

removed removed

Lines of Context:
246
246
        auth = 'Basic ' + userpass.encode('base64').strip()
247
247
        self.headers['Authorization'] = auth
248
248
 
 
249
    def login_oauth2(self, token):
 
250
        """Prepare to make OAuth2 calls to Fluidinfo.
 
251
 
 
252
        :param token: The OAuth token to pass in calls to Fluidinfo.
 
253
        """
 
254
        self.headers['Authorization'] = 'oauth2'
 
255
        self.headers['X-FluidDB-Access-Token'] = token
 
256
 
249
257
    def logout(self):
250
258
        """Log out of this FluidDB instance
251
259
        """
252
 
        del self.headers['Authorization']
 
260
        # Use pop here, to avoid catching KeyError if login was never called.
 
261
        self.headers.pop('Authorization', None)
 
262
        self.headers.pop('X-FluidDB-Access-Token', None)