weibo.py 444 B

123456789101112131415
  1. from json import loads, dumps
  2. from oauthlib.common import to_unicode
  3. def weibo_compliance_fix(session):
  4. def _missing_token_type(r):
  5. token = loads(r.text)
  6. token["token_type"] = "Bearer"
  7. r._content = to_unicode(dumps(token)).encode("UTF-8")
  8. return r
  9. session._client.default_token_placement = "query"
  10. session.register_compliance_hook("access_token_response", _missing_token_type)
  11. return session