27#include <olp/authentication/AuthenticationCredentials.h>
28#include <olp/authentication/ErrorResponse.h>
29#include <olp/authentication/Settings.h>
30#include <olp/authentication/Types.h>
31#include <olp/core/client/CancellationContext.h>
32#include <olp/core/client/OauthToken.h>
33#include <olp/core/http/HttpStatusCode.h>
36namespace authentication {
38static constexpr auto kDefaultMinimumValidity = 300ll;
39static constexpr auto kDefaultMinimumValiditySeconds =
40 std::chrono::seconds(kDefaultMinimumValidity);
41static constexpr auto kForceRefresh = std::chrono::seconds(0);
45class TokenProviderPrivate;
79 std::shared_ptr<TokenProviderPrivate> impl_;
93template <u
int64_t MinimumVal
idity>
103 : impl_(std::make_shared<internal::TokenProviderImpl>(
104 std::move(settings), std::chrono::seconds(MinimumValidity))) {}
126 operator bool()
const {
return impl_->IsTokenResponseOK(); }
138 return impl_->operator()(context);
158 std::shared_ptr<internal::TokenProviderImpl> impl_;
Provides the authentication tokens if the HERE platform user credentials are valid.
Definition TokenProvider.h:94
TokenProvider & operator=(TokenProvider &&other) noexcept=default
A default move assignment operator.
int GetHttpStatusCode() const
Gets the HTTP status code of the last request.
Definition TokenProvider.h:155
TokenProvider(const TokenProvider &other)=default
A default copy constructor.
client::OauthTokenResponse operator()(client::CancellationContext &context) const
Returns the access token or an error.
Definition TokenProvider.h:136
TokenProvider(TokenProvider &&other) noexcept=default
A default move constructor.
TokenProvider(Settings settings)
Creates the TokenProvider instance with the settings parameter.
Definition TokenProvider.h:102
TokenProvider & operator=(const TokenProvider &other)=default
A default copy assignment operator.
ErrorResponse GetErrorResponse() const
Allows the olp::client::ApiError object associated with the last request to be accessed if the token ...
Definition TokenProvider.h:147
Definition TokenProvider.h:50
client::OauthTokenResponse operator()(client::CancellationContext &context) const
TokenResponse GetResponse(client::CancellationContext &context) const
TokenProviderImpl(Settings settings, std::chrono::seconds minimum_validity)
Creates the TokenProviderImpl instance.
bool IsTokenResponseOK() const
int GetHttpStatusCode() const
Gets the HTTP status code of the last request.
ErrorResponse GetErrorResponse() const
Allows the olp::client::ApiError object associated with the last request to be accessed if the token ...
Represents a request outcome.
Definition ApiResponse.h:65
A wrapper that manages the cancellation state of an asynchronous operation in a thread-safe way.
Definition CancellationContext.h:40
Rules all the other namespaces.
Definition AppleSignInProperties.h:24
Detailed descriptions of errors returned as a response to an authentication operation.
Definition ErrorResponse.h:36
Configures the TokenEndpoint instance.
Definition Settings.h:49