diff options
author | Kenji Imamula <kenji.imamula@gmail.com> | 2020-07-31 05:40:02 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-30 20:40:02 +0000 |
commit | 20f82e22b7e8c6c7fdd29e08eaf7b4cf2abdcf37 (patch) | |
tree | 1a004ca5dd896413d13ed3cd049559ced95bb3c4 /tests | |
parent | 8e45f0b16d5bf87698de9bc16891f43ead71d433 (diff) | |
download | google-auth-library-python-20f82e22b7e8c6c7fdd29e08eaf7b4cf2abdcf37.tar.gz |
fix: set Content-Type header in the request to signBlob API to avoid Invalid JSON payload error (#439)
`auth.create_custom_token()` results in an error:
```
Failed to sign custom token. Error calling the IAM signBytes API:{ (...)
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"{\"bytesToSign\": \"...\"}\": Cannot bind query parameter. Field '{\"bytesToSign\": \"...\"}' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"{\"bytesToSign\": \"...\"}\": Cannot bind query parameter. Field '{\"bytesToSign\": \"...\"}' could not be found in request message."
}
]
}
]
}
}
```
I have confirmed setting `'Content-Type': 'application/json'` header resolves the problem.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_iam.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/test_iam.py b/tests/test_iam.py index 4367fe7..cb2c26f 100644 --- a/tests/test_iam.py +++ b/tests/test_iam.py @@ -89,6 +89,8 @@ class TestSigner(object): returned_signature = signer.sign("123") assert returned_signature == signature + kwargs = request.call_args.kwargs + assert kwargs["headers"]["Content-Type"] == "application/json" def test_sign_bytes_failure(self): request = make_request(http_client.UNAUTHORIZED) |