Google Cloud Storage C++ Client
1.42.0
A C++ Client Library for Google Cloud Storage
oauth2
credential_constants.h
Go to the documentation of this file.
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
21
namespace
google
{
22
namespace
cloud
{
23
namespace
storage
{
24
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
25
namespace
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
// NOLINTNEXTLINE(readability-identifier-naming)
34
enum
class
JwtSigningAlgorithms
{
RS256
};
35
36
/// The max lifetime in seconds of an access token.
37
constexpr
std::chrono::seconds
GoogleOAuthAccessTokenLifetime
() {
38
return
std::chrono::seconds(3600);
39
}
40
41
/**
42
* Returns the slack to consider when checking if an access token is expired.
43
*
44
* This time should be subtracted from a token's expiration time when checking
45
* if it is expired. This prevents race conditions where, for example, one might
46
* check expiration time one second before the expiration, see that the token is
47
* still valid, then attempt to use it two seconds later and receive an
48
* error.
49
*/
50
constexpr
std::chrono::seconds
GoogleOAuthAccessTokenExpirationSlack
() {
51
return
std::chrono::seconds(300);
52
}
53
54
/// The endpoint to fetch an OAuth 2.0 access token from.
55
inline
char
const
*
GoogleOAuthRefreshEndpoint
() {
56
static
constexpr
char
kEndpoint[] =
"https://oauth2.googleapis.com/token"
;
57
return
kEndpoint;
58
}
59
60
/// String representing the "cloud-platform" OAuth 2.0 scope.
61
inline
char
const
*
GoogleOAuthScopeCloudPlatform
() {
62
static
constexpr
char
kScope[] =
63
"https://www.googleapis.com/auth/cloud-platform"
;
64
return
kScope;
65
}
66
}
// namespace oauth2
67
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
68
}
// namespace storage
69
}
// namespace cloud
70
}
// namespace google
71
72
#
endif
// GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OAUTH2_CREDENTIAL_CONSTANTS_H
Generated on Thu Sep 15 2022 21:56:57 for Google Cloud Storage C++ Client by
1.9.1