File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 2222// [START apikeys_authenticate_api_key]
2323#include " google/cloud/language/v1/language_client.h"
2424#include " google/cloud/common_options.h"
25+ #include " google/cloud/grpc_options.h"
2526#include " google/cloud/options.h"
2627
2728// [END apikeys_authenticate_api_key]
@@ -82,7 +83,10 @@ void AuthenticateWithApiKey(std::vector<std::string> const& argv) {
8283 " authenticate-with-api-key <project-id> <api-key>" };
8384 }
8485 namespace gc = ::google::cloud;
85- auto options = gc::Options{}.set <gc::ApiKeyOption>(argv[1 ]);
86+ auto options =
87+ gc::Options{}
88+ .set <gc::GrpcCredentialOption>(grpc::SslCredentials ({}))
89+ .set <gc::CustomHeadersOption>({{" x-goog-api-key" , argv[1 ]}});
8690 auto client = gc::language_v1::LanguageServiceClient (
8791 gc::language_v1::MakeLanguageServiceConnection (options));
8892
@@ -150,6 +154,7 @@ void AutoRun(std::vector<std::string> const& argv) {
150154
151155 try {
152156 AuthenticateWithApiKey ({project_id, key.key_string ()});
157+ break ;
153158 } catch (gc::Status const & s) {
154159 if (backoff == 0 ) throw (s);
155160 std::cout << " Sleeping for " << backoff << " seconds\n " ;
You can’t perform that action at this time.
0 commit comments