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 / weibo.py @ 564
History | View | Annotate | Download (482 Bytes)
1 |
from json import loads, dumps |
---|---|
2 |
|
3 |
from oauthlib.common import to_unicode |
4 |
|
5 |
|
6 |
def weibo_compliance_fix(session): |
7 |
|
8 |
def _missing_token_type(r): |
9 |
token = loads(r.text) |
10 |
token['token_type'] = 'Bearer' |
11 |
r._content = to_unicode(dumps(token)).encode('UTF-8')
|
12 |
return r
|
13 |
|
14 |
session._client.default_token_placement = 'query'
|
15 |
session.register_compliance_hook('access_token_response',
|
16 |
_missing_token_type) |
17 |
return session
|