# How to Override the Authentication Credentials

3.7.0-rc 3.6.0 (latest) 3.5.0 3.4.0 3.3.0 3.2.0 2.48.0-rc 2.47.1 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.38.0 2.37.0 Unless otherwise configured, the client libraries use [Application Default Credentials](https://cloud.google.com/docs/authentication#adc) 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](https://docs.cloud.google.com/cpp/docs/reference/common/latest/structgoogle_1_1cloud_1_1UnifiedCredentialsOption.html) 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 =
            google::cloud::Options{}.set<google::cloud::UnifiedCredentialsOption>(
                google::cloud::MakeServiceAccountCredentials(contents));
        return google::cloud::storagebatchoperations_v1::
            StorageBatchOperationsClient(
                google::cloud::storagebatchoperations_v1::
                    MakeStorageBatchOperationsConnection(options));
      }

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](https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys) guide for more details.

###### See Also

[Authentication Components](https://docs.cloud.google.com/cpp/docs/reference/common/latest/group__guac.html) - for more information on the factory functions to create [`google::cloud::Credentials`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1Credentials.html) objects.