Google Cloud Storage C++ Client 2.13.0
A C++ Client Library for Google Cloud Storage
Loading...
Searching...
No Matches
credential_constants.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_CREDENTIAL_CONSTANTS_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OAUTH2_CREDENTIAL_CONSTANTS_H
17
18#include "google/cloud/storage/version.h"
19#include <chrono>
20
21namespace google {
22namespace cloud {
23namespace storage {
24GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
25namespace oauth2 {
26
27/**
28 * Supported signing algorithms used in JWT auth flows.
29 *
30 * We currently only support RSA with SHA-256, but use this enum for
31 * readability and easy addition of support for other algorithms.
32 *
33 * @deprecated Prefer using the unified credentials documented in @ref guac
34 */
35// NOLINTNEXTLINE(readability-identifier-naming)
36enum class JwtSigningAlgorithms { RS256 };
37
38/**
39 * The max lifetime in seconds of an access token.
40 *
41 * @deprecated Prefer using the unified credentials documented in @ref guac
42 */
43constexpr std::chrono::seconds GoogleOAuthAccessTokenLifetime() {
44 return std::chrono::seconds(3600);
45}
46
47/**
48 * Returns the slack to consider when checking if an access token is expired.
49 *
50 * This time should be subtracted from a token's expiration time when checking
51 * if it is expired. This prevents race conditions where, for example, one might
52 * check expiration time one second before the expiration, see that the token is
53 * still valid, then attempt to use it two seconds later and receive an
54 * error.
55 *
56 * @deprecated Prefer using the unified credentials documented in @ref guac
57 */
58constexpr std::chrono::seconds GoogleOAuthAccessTokenExpirationSlack() {
59 return std::chrono::seconds(300);
60}
61
62/**
63 * The endpoint to fetch an OAuth 2.0 access token from.
64 *
65 * @deprecated Prefer using the unified credentials documented in @ref guac
66 */
67inline char const* GoogleOAuthRefreshEndpoint() {
68 static constexpr char kEndpoint[] = "https://oauth2.googleapis.com/token";
69 return kEndpoint;
70}
71
72/**
73 * String representing the "cloud-platform" OAuth 2.0 scope.
74 *
75 * @deprecated Prefer using the unified credentials documented in @ref guac
76 */
77inline char const* GoogleOAuthScopeCloudPlatform() {
78 static constexpr char kScope[] =
79 "https://www.googleapis.com/auth/cloud-platform";
80 return kScope;
81}
82
83} // namespace oauth2
84GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
85} // namespace storage
86} // namespace cloud
87} // namespace google
88
89#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OAUTH2_CREDENTIAL_CONSTANTS_H
Authentication components for Google Cloud Storage.
Definition: anonymous_credentials.h:26
constexpr std::chrono::seconds GoogleOAuthAccessTokenExpirationSlack()
Returns the slack to consider when checking if an access token is expired.
Definition: credential_constants.h:58
char const * GoogleOAuthRefreshEndpoint()
The endpoint to fetch an OAuth 2.0 access token from.
Definition: credential_constants.h:67
constexpr std::chrono::seconds GoogleOAuthAccessTokenLifetime()
The max lifetime in seconds of an access token.
Definition: credential_constants.h:43
JwtSigningAlgorithms
Supported signing algorithms used in JWT auth flows.
Definition: credential_constants.h:36
char const * GoogleOAuthScopeCloudPlatform()
String representing the "cloud-platform" OAuth 2.0 scope.
Definition: credential_constants.h:77
Contains all the Google Cloud Storage C++ client APIs.
Definition: auto_finalize.h:24