olp-cpp-sdk  1.22.0
TokenResult.h
1 /*
2  * Copyright (C) 2019-2024 HERE Europe B.V.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * SPDX-License-Identifier: Apache-2.0
17  * License-Filename: LICENSE
18  */
19 
20 #pragma once
21 
22 #include <boost/optional.hpp>
23 #include <chrono>
24 #include <ctime>
25 #include <string>
26 
27 #include "AuthenticationApi.h"
28 #include "ErrorResponse.h"
29 
30 namespace olp {
31 namespace authentication {
39 class AUTHENTICATION_API TokenResult {
40  public:
49  TokenResult(std::string access_token, time_t expiry_time,
50  boost::optional<std::string> scope);
51 
59  TokenResult(std::string access_token, std::chrono::seconds expires_in,
60  boost::optional<std::string> scope);
64  TokenResult() = default;
65 
71  const std::string& GetAccessToken() const;
72 
80  time_t GetExpiryTime() const;
81 
87  std::chrono::seconds GetExpiresIn() const;
88 
95  const boost::optional<std::string>& GetScope() const;
96 
97  private:
98  std::string access_token_;
99  time_t expiry_time_{};
100  std::chrono::seconds expires_in_{};
101  boost::optional<std::string> scope_;
102 };
103 
104 } // namespace authentication
105 } // namespace olp
A parsed response received from the OAuth2.0 token endpoint.
Definition: TokenResult.h:39
time_t GetExpiryTime() const
Gets the Epoch time when the token expires, or -1 if the token is invalid.
std::chrono::seconds GetExpiresIn() const
Gets the access token expiry time.
TokenResult(std::string access_token, time_t expiry_time, boost::optional< std::string > scope)
Creates the TokenResult instance.
TokenResult(std::string access_token, std::chrono::seconds expires_in, boost::optional< std::string > scope)
Creates the TokenResult instance.
const boost::optional< std::string > & GetScope() const
Gets the scope that is assigned to the access token.
TokenResult()=default
Creates the default TokenResult instance.
const std::string & GetAccessToken() const
Gets the access token issued by the authorization server.
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24