Android-cuttlefish cvd tool
service_account_oauth_credential_source.h
Go to the documentation of this file.
1//
2// Copyright (C) 2019 The Android Open Source Project
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#pragma once
17
18#include <chrono>
19#include <memory>
20#include <string>
21#include <utility>
22
23#include "json/value.h"
24#include "openssl/evp.h"
25
29
30namespace cuttlefish {
31
32// OAuth2 tokens from service account files.
33//
34// https://developers.google.com/identity/protocols/oauth2/service-account
36 public:
38 HttpClient& http_client, const Json::Value& service_account_json,
39 const std::string& scope);
40
41 private:
43
45
47 std::string email_;
48 std::string scope_;
49 std::unique_ptr<EVP_PKEY, void (*)(EVP_PKEY*)> private_key_;
50};
51
52} // namespace cuttlefish
Definition: http_client.h:100
Definition: refreshing_credential_source.h:30
Definition: service_account_oauth_credential_source.h:35
HttpClient & http_client_
Definition: service_account_oauth_credential_source.h:46
Result< std::pair< std::string, std::chrono::seconds > > Refresh() override
Definition: service_account_oauth_credential_source.cc:148
std::string scope_
Definition: service_account_oauth_credential_source.h:48
ServiceAccountOauthCredentialSource(HttpClient &http_client)
Definition: service_account_oauth_credential_source.cc:143
std::unique_ptr< EVP_PKEY, void(*)(EVP_PKEY *)> private_key_
Definition: service_account_oauth_credential_source.h:49
std::string email_
Definition: service_account_oauth_credential_source.h:47
static Result< std::unique_ptr< ServiceAccountOauthCredentialSource > > FromJson(HttpClient &http_client, const Json::Value &service_account_json, const std::string &scope)
Definition: service_account_oauth_credential_source.cc:116
Definition: alloc_driver.h:21
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30