From fde57457076c586fea4b371952b6c31635670c84 Mon Sep 17 00:00:00 2001 From: Brent Bumann Date: Fri, 21 May 2021 15:42:05 -0700 Subject: [PATCH] Refresh Access token when no expiration is present (#241) Co-authored-by: Brent Bumann --- dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs b/dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs index 04b3394bd7..0513cbd5ee 100644 --- a/dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs +++ b/dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs @@ -640,7 +640,8 @@ private async Task RequestJsonString( private async Task CheckAndRefreshAccessToken() { bool canRefresh = this.options.OAuth2RefreshToken != null && this.options.AppKey != null; - bool needsRefresh = this.options.OAuth2AccessTokenExpiresAt.HasValue && DateTime.Now.AddSeconds(TokenExpirationBuffer) >= this.options.OAuth2AccessTokenExpiresAt.Value; + bool needsRefresh = (this.options.OAuth2AccessTokenExpiresAt.HasValue && DateTime.Now.AddSeconds(TokenExpirationBuffer) >= this.options.OAuth2AccessTokenExpiresAt.Value) || + (this.options.OAuth2RefreshToken != null && !this.options.OAuth2AccessTokenExpiresAt.HasValue); bool needsToken = this.options.OAuth2AccessToken == null; if ((needsRefresh || needsToken) && canRefresh) {