Skip to content

Commit

Permalink
Merge pull request requests#138 from shonenada/add-douban-complicance…
Browse files Browse the repository at this point in the history
…-fix

add another compliance for douban
  • Loading branch information
ib-lundgren committed Sep 1, 2014
2 parents 8f0827c + 1aeda8b commit 3649b2e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions requests_oauthlib/compliance_fixes/douban.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import json

from oauthlib.common import to_unicode


def douban_compliance_fix(session):

def fix_token_type(r):
token = json.loads(r.text)
token.setdefault('token_type', 'Bearer')
fixed_token = json.dumps(token)
r._content = to_unicode(fixed_token).encode('utf-8')
return r

session._client_default_token_placement = 'query'
session.register_compliance_hook('access_token_response', fix_token_type)

return session

0 comments on commit 3649b2e

Please sign in to comment.