Hey, I'm developing a web app that should upload files to Dropbox in the final step. All application users use the same Dropbox account, so all the files go to the same Dropbox. I implemented it according to this documentation. When the time comes to upload files, I retrieve the Authorize Uri, send this Uri to the frontend, and then send the returned Dropbox Uri to the backend in order to get an access token and a refresh token. After that, I have the access token and the refresh token stored in local storage, everything goes well until some time passes (3 days in my case passed). When a few days pass and I try to upload files again with the same access token and refresh token I receive the next error:
{"message":"Response status code does not indicate success: 400 (Bad Request).","details":"at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()\r\n at Dropbox.Api.DropboxRequestHandler.RefreshAccessToken(String[] scopeList)\r\n at Dropbox.Api.DropboxRequestHandler.CheckAndRefreshAccessToken()\r\n at Dropbox.Api.DropboxRequestHandler.RequestJsonStringWithRetry(String host, String routeName, String auth, RouteStyle routeStyle, String requestArg, Stream body)\r\n at Dropbox.Api.DropboxRequestHandler.Dropbox.Api.Stone.ITransport.SendRpcRequestAsync[TRequest,TResponse,TError](TRequest request, String host, String route, String auth, IEncoder\u00601 requestEncoder, IDecoder\u00601 responseDecoder, IDecoder\u00601 errorDecoder)\r\n at MY_APP_PATH","type":"HttpRequestException"}
Before uploading files I check if the tokens are from the correct user, and it fails there:
public async Task<bool> IsCorrectUser(string accessToken, string refreshToken)
{
using DropboxClient dropboxClient = new(
accessToken,
refreshToken,
_options.AppKey,
_options.AppSecret,
new DropboxClientConfig("somestring"));
FullAccount account = await dropboxClient.Users.GetCurrentAccountAsync();
return account.Email == _options.AdminEmail;
}From the code above, you can see that I create a client before checking the user and I also create a new client before uploading files.
So my question is, why access token can't be refreshed? Can this issue occur because multiple users use the same Dropbox account, and if so, how can I overcome this issue, because I need to upload my files to the same Dropbox into the same folder?