Skip to content

Commit

Permalink
Refresh Access token when no expiration is present (#241)
Browse files Browse the repository at this point in the history
Co-authored-by: Brent Bumann <[email protected]>
  • Loading branch information
Brent1LT and Brent Bumann authored May 21, 2021
1 parent 5321cec commit fde5745
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dropbox-sdk-dotnet/Dropbox.Api/DropboxRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,8 @@ private async Task<Result> RequestJsonString(
private async Task<bool> 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)
{
Expand Down

0 comments on commit fde5745

Please sign in to comment.