Google Cloud Storage C++ Client 2.13.0
A C++ Client Library for Google Cloud Storage
Loading...
Searching...
No Matches
credentials.h
1// Copyright 2018 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// https://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#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OAUTH2_CREDENTIALS_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OAUTH2_CREDENTIALS_H
17
18#include "google/cloud/storage/signed_url_options.h"
19#include "google/cloud/storage/version.h"
20#include "google/cloud/status.h"
21#include "google/cloud/status_or.h"
22#include <string>
23#include <vector>
24
25namespace google {
26namespace cloud {
27namespace storage {
28GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
29/**
30 * Authentication components for Google Cloud Storage.
31 *
32 * @deprecated Prefer using the unified credentials documented in @ref guac
33 */
34namespace oauth2 {
35
36/**
37 * Interface for OAuth 2.0 credentials used to access Google Cloud services.
38 *
39 * Instantiating a specific kind of `Credentials` should usually be done via the
40 * convenience methods declared in google_credentials.h.
41 *
42 * @see https://cloud.google.com/docs/authentication/ for an overview of
43 * authenticating to Google Cloud Platform APIs.
44 *
45 * @deprecated Prefer using the unified credentials documented in @ref guac
46 */
47class Credentials {
48 public:
49 virtual ~Credentials() = default;
50
51 /**
52 * Attempts to obtain a value for the Authorization HTTP header.
53 *
54 * If unable to obtain a value for the Authorization header, which could
55 * happen for `Credentials` that need to be periodically refreshed, the
56 * underlying `Status` will indicate failure details from the refresh HTTP
57 * request. Otherwise, the returned value will contain the Authorization
58 * header to be used in HTTP requests.
59 *
60 * @deprecated Prefer using the unified credentials documented in @ref guac
61 */
62 virtual StatusOr<std::string> AuthorizationHeader() = 0;
63
64 /**
65 * Try to sign @p string_to_sign using @p service_account.
66 *
67 * Some %Credentials types can locally sign a blob, most often just on behalf
68 * of an specific service account. This function returns an error if the
69 * credentials cannot sign the blob at all, or if the service account is a
70 * mismatch.
71 *
72 * @deprecated Prefer using the unified credentials documented in @ref guac
73 */
74 virtual StatusOr<std::vector<std::uint8_t>> SignBlob(
75 SigningAccount const& service_account,
76 std::string const& string_to_sign) const;
77
78 /**
79 * Return the account's email associated with these credentials, if any.
80 *
81 * @deprecated Prefer using the unified credentials documented in @ref guac
82 */
83 virtual std::string AccountEmail() const { return std::string{}; }
84
85 /**
86 * Return the account's key_id associated with these credentials, if any.
87 *
88 * @deprecated Prefer using the unified credentials documented in @ref guac
89 */
90 virtual std::string KeyId() const { return std::string{}; }
91};
92
93} // namespace oauth2
94GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
95} // namespace storage
96} // namespace cloud
97} // namespace google
98
99#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OAUTH2_CREDENTIALS_H
Interface for OAuth 2.0 credentials used to access Google Cloud services.
Definition: credentials.h:47
virtual std::string KeyId() const
Return the account's key_id associated with these credentials, if any.
Definition: credentials.h:90
virtual StatusOr< std::string > AuthorizationHeader()=0
Attempts to obtain a value for the Authorization HTTP header.
virtual std::string AccountEmail() const
Return the account's email associated with these credentials, if any.
Definition: credentials.h:83
virtual StatusOr< std::vector< std::uint8_t > > SignBlob(SigningAccount const &service_account, std::string const &string_to_sign) const
Try to sign string_to_sign using service_account.
Authentication components for Google Cloud Storage.
Definition: anonymous_credentials.h:26
Contains all the Google Cloud Storage C++ client APIs.
Definition: auto_finalize.h:24
Specify the service account used to sign a blob.
Definition: signed_url_options.h:186