Skip to content

Commit

Permalink
fix: set Content-Type header in the request to signBlob API to avoid …
Browse files Browse the repository at this point in the history
…Invalid JSON payload error
  • Loading branch information
kimamula committed Feb 8, 2020
1 parent 054db75 commit 632808a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
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
1 change: 1 addition & 0 deletions tests/test_iam.py
Expand Up @@ -86,6 +86,7 @@ def test_sign_bytes(self):
returned_signature = signer.sign("123")

assert returned_signature == signature
assert request.call_args.kwargs.get("headers").get("Content-Type") == "application/json"

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

0 comments on commit 632808a

Please sign in to comment.