Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Commit 10d0c87

Browse files
committed
add accesstoken interface
1 parent 46b4a32 commit 10d0c87

3 files changed

Lines changed: 113 additions & 0 deletions

File tree

src/cpp/accesstoken/src/BUILD

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
load("@rules_cc//cc:defs.bzl", "cc_library")
16+
17+
package(default_visibility = ["//visibility:public"])
18+
19+
cc_library(
20+
name = "accesstoken_fetcher",
21+
srcs = ["accesstoken_fetcher_manager.cc"],
22+
hdrs = ["accesstoken_fetcher_manager.h"],
23+
deps = [
24+
"@com_github_google_glog//:glog",
25+
"@com_google_absl//absl/container:flat_hash_map",
26+
"@com_google_absl//absl/random",
27+
"@com_google_absl//absl/strings:str_format",
28+
"//scp/cc/public/core/interface:errors"
29+
],
30+
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <memory>
2+
3+
#include "public/core/interface/execution_result.h"
4+
#include "src/cpp/accesstoken/src/accesstoken_fetcher_manager.h"
5+
6+
namespace privacy_sandbox::server_common {
7+
8+
AccessTokenClientFactory::AccessTokenClientFactory(
9+
const AccessTokenClientOptions& options) noexcept
10+
: options_(options) {
11+
// Constructor implementation
12+
}
13+
14+
std::unique_ptr<AccessTokenClientFactory> AccessTokenClientFactory::Create(
15+
const AccessTokenClientOptions& options) noexcept {
16+
return std::make_unique<AccessTokenClientFactory>(options);
17+
}
18+
19+
// GetAccessToken
20+
std::string AccessTokenClientFactory::GetAccessToken() {
21+
// Use options_ to retrieve the access token
22+
// The implementation details will depend on how you retrieve the token
23+
std::string token = "some_logic_to_get_token_based_on_options_";
24+
return token;
25+
}
26+
27+
} // namespace privacy_sandbox::server_common
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

Comments
 (0)