commit | a57a7708cfea635b5030f8c7ba10c967715f9a87 | [log] [tgz] |
---|---|---|
author | Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> | Fri Jan 10 13:17:34 2020 -0800 |
committer | GitHub <noreply@github.com> | Fri Jan 10 13:17:34 2020 -0800 |
tree | 5ec711eb73488d47837285dc962c2aaaf39d3a9d | |
parent | af29c1a9fd9282b38867961e4053f74f018a3815 [diff] [blame] |
fix: always pass body of type bytes to `google.auth.transport.Request` (#421) [`google.auth.transport.Request`](https://google-auth.readthedocs.io/en/latest/reference/google.auth.transport.html#google.auth.transport.Request) says that the body should be of type bytes. Some of our code was passing in strings as reported in #318. In practice this was not causing issues, as the two http transports [requests](https://google-auth.readthedocs.io/en/latest/reference/google.auth.transport.requests.html) and [urllib3](https://google-auth.readthedocs.io/en/latest/reference/google.auth.transport.urllib3.html) are able to handle bodies passed as strings.
diff --git a/google/oauth2/_client.py b/google/oauth2/_client.py index 4cf7a7f..4ba31a8 100644 --- a/google/oauth2/_client.py +++ b/google/oauth2/_client.py
@@ -95,7 +95,7 @@ google.auth.exceptions.RefreshError: If the token endpoint returned an error. """ - body = urllib.parse.urlencode(body) + body = urllib.parse.urlencode(body).encode("utf-8") headers = {"content-type": _URLENCODED_CONTENT_TYPE} retry = 0