Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set Content-Type header in the request to signBlob API to avoid Invalid JSON payload error #439

Merged
merged 8 commits into from Jul 30, 2020
2 changes: 1 addition & 1 deletion google/auth/iam.py
Expand Up @@ -69,7 +69,7 @@ def _make_signing_request(self, message):

method = "POST"
url = _SIGN_BLOB_URI.format(self._service_account_email)
headers = {}
headers = {"Content-Type": "application/json"}
body = json.dumps(
{"bytesToSign": base64.b64encode(message).decode("utf-8")}
).encode("utf-8")
Expand Down
2 changes: 2 additions & 0 deletions tests/test_iam.py
Expand Up @@ -86,6 +86,8 @@ def test_sign_bytes(self):
returned_signature = signer.sign("123")

assert returned_signature == signature
kwargs = request.call_args.kwargs
assert kwargs.get("headers").get("Content-Type") == "application/json"
tseaver marked this conversation as resolved.
Show resolved Hide resolved

def test_sign_bytes_failure(self):
request = make_request(http_client.UNAUTHORIZED)
Expand Down