The current code assumes that response_data will always be a dict or a mapping of some kind, but it is possible for response_data to be a str.
When response_data is a str, then the function fails on response_data.get("error") but the error response is swallowed so the user doesn't know why it failed. The user just sees: AttributeError: 'str' object has no attribute 'get' and a stacktrace
This is a quick and dirty fix that guarantees the .get call will succeed, and the result is that the error response bubbles up to the user.
Expected: Authentication should fail with a useful error response
Actual: Authentication fails with an AttributeError: "AttributeError: 'str' object has no attribute 'get'"
response_data
will always be adict
or a mapping of some kind, but it is possible forresponse_data
to be astr
.response_data
is astr
, then the function fails onresponse_data.get("error")
but the error response is swallowed so the user doesn't know why it failed. The user just sees:AttributeError: 'str' object has no attribute 'get'
and a stacktrace.get
call will succeed, and the result is that the error response bubbles up to the user.Steps to reproduce the bug
But ensure that there is a typo in GCP_TOKEN_URI. Example: "https://oauth2.googleapis.com/token1"
Expected: Authentication should fail with a useful error response Actual: Authentication fails with an AttributeError: "AttributeError: 'str' object has no attribute 'get'"