]> projects.mako.cc - twitter-api-cdsw-solutions/blob - requests_oauthlib/compliance_fixes/douban.py
Switched to stdout codec, and switched ignore to replace. This could be a teaching...
[twitter-api-cdsw-solutions] / requests_oauthlib / compliance_fixes / douban.py
1 import json
2
3 from oauthlib.common import to_unicode
4
5
6 def douban_compliance_fix(session):
7
8     def fix_token_type(r):
9         token = json.loads(r.text)
10         token.setdefault('token_type', 'Bearer')
11         fixed_token = json.dumps(token)
12         r._content = to_unicode(fixed_token).encode('utf-8')
13         return r
14
15     session._client_default_token_placement = 'query'
16     session.register_compliance_hook('access_token_response', fix_token_type)
17
18     return session

Benjamin Mako Hill || Want to submit a patch?