Closed GregShiner closed 2 years ago
Thanks for reporting that, This is supposed to be handled as intended here and here, but i can see where the issue is happening, the await response.json()
line is being called before checking if the response status is == 200
, so when you get 401 Bungie returns an HTML instead of JSON. which gets kinda funky with my impl for reading JSON only. anyways I will fix this ASAP.
Also the response code its returning is actually 500 internal error not 401, which's why i'm hardcoding this to return useful information.
Long story short.
If the token given to any function that uses OAuth is invalid or expired, bungie.net returns an HTML error that rest.py fails to parse.
Expected Result
The simplest solution would be to catch this specific error (401 unauthorized) and raise a more specific and helpful error than the one shown below.
Actual Result
The error shown here makes it really unclear what actually happened. All a normal user could maybe deduce is that Bungie is returning HTML as opposed to JSON. But I know that the specific time this error occurred, it was caused by Bungie returning 401 unauthorized.
response.status
when this error is thrown is401
.System info
OS: Ubuntu 20.04.03 LTS Python: 3.9.5 aiobungie: 0.2.5
Further info