Google Cloud BigQuery C++ Client 2.13.0
A C++ Client Library for Google Cloud BigQuery
Loading...
Searching...
No Matches
How to Override the Authentication Credentials

Unless otherwise configured, the client libraries use Application Default Credentials to authenticate with Google Cloud Services. While this works for most applications, in some cases you may need to override this default. You can do so by providing the UnifiedCredentialsOption The following example shows how to explicitly load a service account key file:

[](std::string const& keyfile) {
auto is = std::ifstream(keyfile);
is.exceptions(std::ios::badbit); // Minimal error handling in examples
auto contents = std::string(std::istreambuf_iterator<char>(is.rdbuf()), {});
auto options =
MakeAnalyticsHubServiceConnection(options));
}
Options & set(ValueTypeT< T > v)
The AnalyticsHubService API facilitates data sharing within and across organizations.
Definition: analytics_hub_client.h:66
std::shared_ptr< Credentials > MakeServiceAccountCredentials(std::string json_object, Options opts={})
Definition: analytics_hub_client.h:32

Follow these links to find examples for other *Client classes:

Keep in mind that we chose this as an example because it is relatively easy to understand. Consult the Best practices for managing service account keys guide for more details.

See also
Authentication Components - for more information on the factory functions to create google::cloud::Credentials objects.