Closed CheeseTheMonkey closed 9 years ago
Note that the check there is if k in post_data and not post_data[k]
, so if key is there, but the value (usually grabbed from the config or whatever storage) is empty.
As the values are all public class attrs, check is there to ensure that they were at least set (by whatever means).
So stuff like post_data.update(code=self.auth_code, ...)
+ post_data_keys.append('code')
seem redundant - if you don't add the key, empty value won't be checked.
I wonder, how did you come across the issue? Was that error raised for you in some case where it shouldn't have been (which I don't see how can happen, given the code)?
Also, there seem to be space/tabs issue with the diff, not that it's really relevant though.
You're right, I apparently glossed over that while trying to provide a fix for a colleague.
The context in which the error was obtained was what may have caused confusion:
onedrive_client = api_v5.OneDriveAPI(client_id=APP_ID, client_secret=APP_SECRET, request_extra_keywords = dict(timeout=(20,120)))
#refresh token has been passed into the method previously
onedrive_client.auth_refresh_token = refresh_token
onedrive_client.auth_get_token()
Error raised claims "code" is missing
I'm guessing refresh_token
in the code above was empty, triggering that other code path.
I think good fix for confusion here might be to add "if not code or refresh_token" logic branch, raising proper "no idea how to do auth without either" error instead of going the wrong way (depending on whether there's non-empty refresh_token).
as such, checking for all 5 can raise errors incorrectly.