diff options
Diffstat (limited to 'game/python-extra/requests_oauthlib/compliance_fixes/weibo.py')
-rw-r--r-- | game/python-extra/requests_oauthlib/compliance_fixes/weibo.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/game/python-extra/requests_oauthlib/compliance_fixes/weibo.py b/game/python-extra/requests_oauthlib/compliance_fixes/weibo.py new file mode 100644 index 0000000..6733abe --- /dev/null +++ b/game/python-extra/requests_oauthlib/compliance_fixes/weibo.py @@ -0,0 +1,15 @@ +from json import loads, dumps + +from oauthlib.common import to_unicode + + +def weibo_compliance_fix(session): + def _missing_token_type(r): + token = loads(r.text) + token["token_type"] = "Bearer" + r._content = to_unicode(dumps(token)).encode("UTF-8") + return r + + session._client.default_token_placement = "query" + session.register_compliance_hook("access_token_response", _missing_token_type) + return session |