Token: use DateTime (#1221)

This commit is contained in:
Anton Kolesnyk 2020-12-18 19:10:54 -08:00 committed by GitHub
parent d40b4fb642
commit bdc2931855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 4 deletions

View File

@ -16,6 +16,7 @@
- Moved `Azure::Core::BearerTokenAuthenticationPolicy`, defined in `azure/core/credentials.hpp` to `Azure::Core::Http` namespace in `azure/core/http/policy.hpp` header.
- Removed option `AllowBeast` from `CurlTransportSSLOptions` in `CurlTransportOptions`.
- Changed default option `NoRevoke` from `CurlTransportSSLOptions` for the `CurlTransportOptions` to `true`. This disables the revocation list checking by default.
- Changed type of `Token::ExpiresOn` to `DateTime`.
### Bug Fixes

View File

@ -9,8 +9,8 @@
#pragma once
#include "azure/core/context.hpp"
#include "azure/core/datetime.hpp"
#include <chrono>
#include <exception>
#include <memory>
#include <mutex>
@ -33,7 +33,7 @@ namespace Azure { namespace Core {
/**
* @brief Token expiration.
*/
std::chrono::system_clock::time_point ExpiresOn;
DateTime ExpiresOn;
};
/**

View File

@ -14,7 +14,7 @@ std::unique_ptr<RawResponse> BearerTokenAuthenticationPolicy::Send(
{
std::lock_guard<std::mutex> lock(m_accessTokenMutex);
if (std::chrono::system_clock::now() > m_accessToken.ExpiresOn)
if (DateTime::Now() > m_accessToken.ExpiresOn)
{
m_accessToken = m_credential->GetToken(context, m_scopes);
}

View File

@ -180,7 +180,7 @@ Azure::Core::AccessToken ClientSecretCredential::GetToken(
return {
std::string(responseBodyBegin + tokenBegin, responseBodyBegin + tokenEnd),
std::chrono::system_clock::now()
DateTime::Now()
+ std::chrono::seconds(expiresInSeconds < 0 ? 0 : expiresInSeconds),
};
}