You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In testing a revoked refresh token used when calling Files.ListFolderAsync, the Dropbox SDK threw a generic HttpRequestException with status 400 Bad Request. There is no indication of what failed or why.
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Dropbox.Api.DropboxRequestHandler.RefreshAccessToken(String[] scopeList)
at Dropbox.Api.DropboxRequestHandler.CheckAndRefreshAccessToken()
at Dropbox.Api.DropboxRequestHandler.RequestJsonStringWithRetry(String host, String routeName, String auth, RouteStyle routeStyle, String requestArg, Stream body)
at Dropbox.Api.DropboxRequestHandler.Dropbox.Api.Stone.ITransport.SendRpcRequestAsync[TRequest,TResponse,TError](TRequest request, String host, String route, String auth, IEncoder`1 requestEncoder, IDecoder`1 responseDecoder, IDecoder`1 errorDecoder)
at UserQuery.Main(), line 10
Here is the raw response returned by Fiddler:
{
"error_description": "refresh token is invalid or revoked",
"error": "invalid_grant"
}
If I make a similar request using an old-style long-lived access token, I get an AuthException whose Message is invalid_access_token/.... This I can use to alert the user that my app can no longer communicate with Dropbox on their behalf.
Obtain a short-lived refresh token by having the user authorize the application via OAuth.
Have the user disconnect the app from Connected Apps in their Dropbox.com settings.
Use the refresh token as described in the code snippet above to try to list folders.
Expected Behavior
When trying to use a revoked refresh token, I expect the SDK to throw an AuthException telling me that the refresh token is invalid or has been revoked.
Actual Behavior
The SDK throws a generic HttpRequestException with no details as to what caused the failure.
I believe the issue is in DropboxRequestHandler.cs in the RefreshAccessToken method:
At line 279, it handles an Unauthorized response, but it doesn't handle the 400 Bad Request returned by the API. The subsequent call to response.EnsureSuccessStatusCode(); on line 288 causes the generic HttpRequestException to be thrown.
Would it be possible to add error handling before line 288 to throw an AuthException if it detects an invalid or revoked refresh token?
Versions
What version of the SDK are you using? Dropbox.Api 6.4.0
What version of the language are you using? C# 9.0
What platform are you using? (if applicable)
ASP.NET Core 5.0
.NET SDK 5.0.202
Windows 10 / whatever version of Windows Azure App Service uses
Thank you,
Jon
The text was updated successfully, but these errors were encountered:
Another vote for this. Without being able to inform users that the link is broken, you can end up in a scenario where things like auto backups and/or syncing silently stop working, potentially resulting in data loss for the user.
Describe the bug
In testing a revoked refresh token used when calling
Files.ListFolderAsync
, the Dropbox SDK threw a genericHttpRequestException
with status400 Bad Request
. There is no indication of what failed or why.Here is the sample code that I ran in
LINQPad
:Here is the stack trace of the
HttpRequestException
from the request to https://api.dropbox.com/oauth2/token:Here is the raw response returned by
Fiddler
:If I make a similar request using an old-style long-lived access token, I get an
AuthException
whoseMessage
isinvalid_access_token/...
. This I can use to alert the user that my app can no longer communicate with Dropbox on their behalf.Here is the sample code:
Here is the stack trace of the
AuthException
from the request to https://api.dropboxapi.com/2/files/list_folder:Here is the raw response returned by
Fiddler
:To Reproduce
Connected Apps
in their Dropbox.com settings.Expected Behavior
When trying to use a revoked refresh token, I expect the SDK to throw an
AuthException
telling me that the refresh token is invalid or has been revoked.Actual Behavior
The SDK throws a generic
HttpRequestException
with no details as to what caused the failure.I believe the issue is in
DropboxRequestHandler.cs
in theRefreshAccessToken
method:dropbox-sdk-dotnet/dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs
Lines 275 to 300 in dbd3a37
At line 279, it handles an
Unauthorized
response, but it doesn't handle the400 Bad Request
returned by the API. The subsequent call toresponse.EnsureSuccessStatusCode();
on line 288 causes the genericHttpRequestException
to be thrown.Would it be possible to add error handling before line 288 to throw an
AuthException
if it detects an invalid or revoked refresh token?Versions
Dropbox.Api 6.4.0
C# 9.0
Thank you,
Jon
The text was updated successfully, but these errors were encountered: