Android-cuttlefish cvd tool
refresh_token_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
29
30namespace cuttlefish {
31
32// OAuth2 tokens from a desktop refresh token.
33//
34// https://developers.google.com/identity/protocols/oauth2/native-app
36 public:
39 const std::string& oauth_contents);
40
42 HttpClient& http_client, const std::string& client_id,
43 const std::string& client_secret, const std::string& refresh_token);
44
45 private:
47 const std::string& client_id,
48 const std::string& client_secret,
49 const std::string& refresh_token);
50
52 HttpClient& http_client, const Json::Value& credential);
53
55
57 std::string client_id_;
58 std::string client_secret_;
59 std::string refresh_token_;
60};
61
62} // namespace cuttlefish
Definition: http_client.h:100
Definition: refresh_token_credential_source.h:35
HttpClient & http_client_
Definition: refresh_token_credential_source.h:56
std::string refresh_token_
Definition: refresh_token_credential_source.h:59
static Result< std::unique_ptr< RefreshTokenCredentialSource > > FromOauth2ClientFile(HttpClient &http_client, const std::string &oauth_contents)
Definition: refresh_token_credential_source.cc:65
Result< std::pair< std::string, std::chrono::seconds > > Refresh() override
Definition: refresh_token_credential_source.cc:161
std::string client_id_
Definition: refresh_token_credential_source.h:57
RefreshTokenCredentialSource(HttpClient &http_client, const std::string &client_id, const std::string &client_secret, const std::string &refresh_token)
Definition: refresh_token_credential_source.cc:145
static Result< std::unique_ptr< RefreshTokenCredentialSource > > FromJson(HttpClient &http_client, const Json::Value &credential)
Definition: refresh_token_credential_source.cc:44
std::string client_secret_
Definition: refresh_token_credential_source.h:58
static Result< std::unique_ptr< CredentialSource > > Make(HttpClient &http_client, const std::string &client_id, const std::string &client_secret, const std::string &refresh_token)
Definition: refresh_token_credential_source.cc:153
Definition: refreshing_credential_source.h:30
Definition: alloc_driver.h:21
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30