gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / requests_oauthlib / compliance_fixes / douban.py @ 564
History | View | Annotate | Download (473 Bytes)
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
|