-
I'm working on a standalone library that will be used by other teams. This library integrates multiple google cloud clients to query/pull/push/write data using multiple services (e.g. storage, bigquery, bigtable, etc.). I simply want to provide the library to the end user, they will integrate it into their application and use it. Credentials cannot be shared with the final user of the library. The production environment is controlled by the final user, thus environment variables and json files are not an option. What's the best practice to let my library authenticate and use the services in this scenario? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I am not sure I understand the question, apologies if I missed something. Presumably the consumers of your library have their own credentials to authenticate with Google Cloud Platform. So much like we do for the libraries in You could expose the namespace my_lib {
class Client; // defined elsewhere.
Client MakeClient(std::shared_ptr<google::cloud::Credentials> credentials) {
auto options = google::cloud::Options{}.set<google::cloud::UnifiedCredentialsOption>(std::move(credentials));
auto gcs = google::cloud::storage::Client(options);
auto publisher = google::cloud::pubsub::Publisher(google::cloud::pubsub::MakePublisherConnection(Topic(...), options));
return SecretFactoryFunction(std::move(gcs), std::move(publisher));
}
} There may be good reasons why you don't want to expose If the consumers of your library don't have their own credentials, then I am not sure there is a "best practice". You cannot authenticate without |
Beta Was this translation helpful? Give feedback.
I am not sure I understand the question, apologies if I missed something.
Presumably the consumers of your library have their own credentials to authenticate with Google Cloud Platform. So much like we do for the libraries in
google-cloud-cpp
your library would need to have options to set these credentials. How would they do so? Well, that depends on the API you want to expose.You could expose the
google::cloud::Credentials
directly to them, so your library could do something like: