(body: bytes)
| 1173 | |
| 1174 | |
| 1175 | def _oauth_parse_response(body: bytes) -> Dict[str, Any]: |
| 1176 | # I can't find an officially-defined encoding for oauth responses and |
| 1177 | # have never seen anyone use non-ascii. Leave the response in a byte |
| 1178 | # string for python 2, and use utf8 on python 3. |
| 1179 | body_str = escape.native_str(body) |
| 1180 | p = urllib.parse.parse_qs(body_str, keep_blank_values=False) |
| 1181 | token = dict(key=p["oauth_token"][0], secret=p["oauth_token_secret"][0]) |
| 1182 | |
| 1183 | # Add the extra parameters the Provider included to the token |
| 1184 | special = ("oauth_token", "oauth_token_secret") |
| 1185 | token.update((k, p[k][0]) for k in p if k not in special) |
| 1186 | return token |
no test coverage detected