|
| 1 | +#ifndef SRC_CPP_ACCESSTOKEN_FETCHER_FACTORY_H_ |
| 2 | +#define SRC_CPP_ACCESSTOKEN_FETCHER_FACTORY_H_ |
| 3 | + |
| 4 | +#include <memory> |
| 5 | + |
| 6 | +#include "public/core/interface/execution_result.h" |
| 7 | + |
| 8 | +namespace privacy_sandbox::server_common { |
| 9 | +using AccessTokenServiceEndpoint = std::string; |
| 10 | +using ClientApplicationId = std::string; |
| 11 | +using ClientSecret = std::string; |
| 12 | +using ApiIdentifierUri = std::string; |
| 13 | +using AccessTokenValue = std::string; |
| 14 | + |
| 15 | +// Represents an accesstoken fetched from the token Service. |
| 16 | +struct AccessToken { |
| 17 | + // The value of the accesstoken. This field is the raw, unencoded byte string |
| 18 | + AccessTokenValue accessToken; |
| 19 | +}; |
| 20 | + |
| 21 | +/// Represents the accesstoken response object. |
| 22 | +struct GetAccessTokenResponse { |
| 23 | + std::shared_ptr<std::string> accesstoken; |
| 24 | +}; |
| 25 | +/// Represents the get accesstoken request object. |
| 26 | +struct GetAccessTokenRequest {}; |
| 27 | + |
| 28 | +// Configuration for access token endpoint. |
| 29 | +struct AccessTokenClientOptions { |
| 30 | + virtual ~AccessTokenClientOptions() = default; |
| 31 | + |
| 32 | + AccessTokenServiceEndpoint endpoint; |
| 33 | + ClientApplicationId clientid; |
| 34 | + ClientSecret clientSecret; |
| 35 | + ApiIdentifierUri apiUri; |
| 36 | +}; |
| 37 | + |
| 38 | +class AccessTokenClientFactory { |
| 39 | + public: |
| 40 | + // Constructor that accepts AccessTokenClientOptions |
| 41 | + explicit AccessTokenClientFactory( |
| 42 | + const AccessTokenClientOptions& options) noexcept; |
| 43 | + |
| 44 | + static std::unique_ptr<AccessTokenClientFactory> Create( |
| 45 | + const AccessTokenClientOptions& options) noexcept; |
| 46 | + |
| 47 | + // Method to get access token |
| 48 | + std::string GetAccessToken(); |
| 49 | + |
| 50 | + private: |
| 51 | + AccessTokenClientOptions options_; // Member variable to store the options |
| 52 | +}; |
| 53 | + |
| 54 | +} // namespace server_common::privacy_sandbox |
| 55 | + |
| 56 | +#endif // SRC_CPP_ACCESSTOKEN_FETCHER_FACTORY_H_ |
0 commit comments