Token: use DateTime (#1221)
This commit is contained in:
parent
d40b4fb642
commit
bdc2931855
@ -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
|
||||
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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),
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user