-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth Token failure categorised as General Exception #69
Comments
Here is a unit test to prove the current behaviour:
|
Thanks for the unit test. I'm seeing it pass on the current version (1.2.0) of the library. Which package version are you running? |
The unit test should pass - I wrote it to prove current behaviour. I'm not sure exactly what the SDK should do with the response. The OneDrive API documentation states:
But in this case of "invalid_grant" the response is clearly not in that format. So is it an API mistake? Otherwise the SDK needs to do something different. Confusingly, the OneDrive SDK appears to have code to handle this "error" + "error_description" response body, but because the Graph SDK explodes, in this case it doesn't reach that code (see linked issue). Like I say, is it an API problem or an SDK problem? |
Ok, so the OAUTH docs specifies the "error" + "error_description" response...
It would therefore suggest that the problem is a weakness in the Graph SDK as it doesn't handle deserialising these OAUTH authentication errors. i.e the code in HttpProvider currently will catch the deserialisation exception and ConvertErrorResponseAsync will return null. Perhaps better behaviour would be to handle this and either:
|
Pull request created for option 1. |
See comment on the PR. Thanks for reporting this bug. The error coming from the service is leaking in a format it should not be (per Graph Documentation). The service should be wrapping the OAuth error in a format that calling code expects. |
Looks like it is an API problem as I initially wondered. |
@oatsoda Can you provide the exact call you make to the graph when you see this OAuth error return in this form? We are trying to reproduce the bug but are not having a lot of luck. |
Here is the code we are using. You first need to authenticate with OneDrive and have got a refreshToken. Then change your password with OneDrive. Then authenticate again with the refreshToken as per below:
|
I see what's going on here. I guess this isn't a bug in the service. This is a bug in the OneDrive SDK. This repo is for the Microsoft Graph SDK. I'm going to recreate you a new issue on the OneDrive SDK repo and tag you. I can explain to them what the problem is. Sorry for the confusion. |
New issue filed here: |
If you authenticate with an account and then later change the password on that account - therefore invalidating the token - the
HttpProvider
does not interpret this as an Auth Error - instead it just treats it as a general problem.This is the response from the API:
And this is the exception detail/stack trace:
Because the detail of the original exception is lost, this makes it very difficult to detect that this is an authentication failure.
It should really be ensuring that it presents this problem in a
ServiceException
with the relevantMicrosoft.Graph.Error
object which can then be inspected to see the details.The text was updated successfully, but these errors were encountered: