Google Cloud Storage C++ Client  1.42.0
A C++ Client Library for Google Cloud Storage
anonymous_credentials.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_ANONYMOUS_CREDENTIALS_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OAUTH2_ANONYMOUS_CREDENTIALS_H
17 
18 #include "google/cloud/storage/oauth2/credentials.h"
19 #include "google/cloud/storage/version.h"
20 #include <string>
21 
22 namespace google {
23 namespace cloud {
24 namespace storage {
26 namespace oauth2 {
27 
28 /**
29  * A `Credentials` type representing "anonymous" Google OAuth2.0 credentials.
30  *
31  * This is only useful in two cases: (a) in testing, where you want to access
32  * a test bench without having to worry about authentication or SSL setup, and
33  * (b) when accessing publicly readable resources (e.g. a Google Cloud Storage
34  * object that is readable by the "allUsers" entity), which requires no
35  * authentication or authorization.
36  */
38  public:
39  AnonymousCredentials() = default;
40 
41  /**
42  * While other Credentials subclasses return a string containing an
43  * Authorization HTTP header from this method, this class always returns an
44  * empty string as its value.
45  */
46  StatusOr<std::string> AuthorizationHeader() override;
47 };
48 
49 } // namespace oauth2
51 } // namespace storage
52 } // namespace cloud
53 } // namespace google
54 
55 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_OAUTH2_ANONYMOUS_CREDENTIALS_H