Fix math for bearer token refresh time (#1593)

This commit is contained in:
Sylvain Joubert 2021-02-04 12:29:42 +01:00 committed by GitHub
parent 4f7e8c03bf
commit 2f250f3968
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,9 @@
## 1.0.0-beta.6 (Unreleased)
### Bug Fixes
- Fixed computation of the token expiration time in `BearerTokenAuthenticationPolicy`.
## 1.0.0-beta.5 (2021-02-02)

View File

@ -17,7 +17,7 @@ std::unique_ptr<RawResponse> BearerTokenAuthenticationPolicy::Send(
std::lock_guard<std::mutex> lock(m_accessTokenMutex);
// Refresh the token in 2 or less minutes before the actual expiration.
if ((std::chrono::system_clock::now() - std::chrono::minutes(2)) > m_accessToken.ExpiresOn)
if (std::chrono::system_clock::now() > (m_accessToken.ExpiresOn - std::chrono::minutes(2)))
{
m_accessToken = m_credential->GetToken(context, m_tokenRequestOptions);
}