OneDrive / onedrive-sdk-dotnet-msa-auth-adapter

Other
25 stars 22 forks source link

OAuthHelper.SendTokenRequestAsync cannot retrieve error details from "invalid_grant" response #31

Closed oatsoda closed 7 years ago

oatsoda commented 7 years ago

The following line:

https://github.com/OneDrive/onedrive-sdk-dotnet-msa-auth-adapter/blob/master/src/OneDrive.Sdk.Authentication.Common/OAuthHelper.cs#L285

Will throw an exception in the case of an "invalid_grant" due to the way that Microsoft.Graph fails to attempt to deserialize the response.

Therefore the OAuthErrorHandler.ThrowIfError call is never made to retrieve the error details.

As yet I am not sure whether this is a Microsoft.Graph error or something that the OneDrive.Sdk should handle.

The example response is:

HTTP/1.1 400 Bad Request
Cache-Control: no-store
Pragma: no-cache
Content-Length: 210
Content-Type: application/json
Server: Microsoft-IIS/8.5
X-WLID-Error: 0x8004100C
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000
X-XSS-Protection: 1; mode=block
Date: Tue, 13 Dec 2016 07:57:45 GMT
Connection: close

{"error":"invalid_grant","error_description":"The user could not be authenticated or the grant is expired. The user must first sign in and if needed grant the client application access to the requested scope."}
oatsoda commented 7 years ago

See linked issue logged in Microsoft.Graph. They have confirmed this is a OneDrive API problem.