olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
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 <chrono>
23#include <ctime>
24#include <string>
25
26#include <olp/core/porting/optional.h>
27#include "AuthenticationApi.h"
28#include "ErrorResponse.h"
29
30namespace olp {
31namespace authentication {
39class AUTHENTICATION_API TokenResult {
40 public:
49 TokenResult(std::string access_token, time_t expiry_time,
50 porting::optional<std::string> scope);
51
59 TokenResult(std::string access_token, std::chrono::seconds expires_in,
60 porting::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 porting::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 porting::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.
const std::string & GetAccessToken() const
Gets the access token issued by the authorization server.
TokenResult()=default
Creates the default TokenResult instance.
const porting::optional< std::string > & GetScope() const
Gets the scope that is assigned to the access token.
TokenResult(std::string access_token, std::chrono::seconds expires_in, porting::optional< std::string > scope)
Creates the TokenResult instance.
TokenResult(std::string access_token, time_t expiry_time, porting::optional< std::string > scope)
Creates the TokenResult instance.
Rules all the other namespaces.
Definition AppleSignInProperties.h:24