diff options
Diffstat (limited to 'test/core/security/fetch_oauth2.cc')
-rw-r--r-- | test/core/security/fetch_oauth2.cc | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc index fa8036e581..cb28a0487c 100644 --- a/test/core/security/fetch_oauth2.cc +++ b/test/core/security/fetch_oauth2.cc @@ -38,16 +38,16 @@ static grpc_call_credentials* create_refresh_token_creds( "load_file", grpc_load_file(json_refresh_token_file_path, 1, &refresh_token))); return grpc_google_refresh_token_credentials_create( - (const char*)GRPC_SLICE_START_PTR(refresh_token), NULL); + (const char*)GRPC_SLICE_START_PTR(refresh_token), nullptr); } int main(int argc, char** argv) { - grpc_call_credentials* creds = NULL; - char* json_key_file_path = NULL; - const char* json_refresh_token_file_path = NULL; - char* token = NULL; + grpc_call_credentials* creds = nullptr; + char* json_key_file_path = nullptr; + const char* json_refresh_token_file_path = nullptr; + char* token = nullptr; int use_gce = 0; - char* scope = NULL; + char* scope = nullptr; gpr_cmdline* cl = gpr_cmdline_create("fetch_oauth2"); gpr_cmdline_add_string(cl, "json_refresh_token", "File path of the json refresh token.", @@ -60,26 +60,27 @@ int main(int argc, char** argv) { grpc_init(); - if (json_key_file_path != NULL && json_refresh_token_file_path != NULL) { + if (json_key_file_path != nullptr && + json_refresh_token_file_path != nullptr) { gpr_log(GPR_ERROR, "--json_key and --json_refresh_token are mutually exclusive."); exit(1); } if (use_gce) { - if (json_key_file_path != NULL || scope != NULL) { + if (json_key_file_path != nullptr || scope != nullptr) { gpr_log(GPR_INFO, "Ignoring json key and scope to get a token from the GCE " "metadata server."); } - creds = grpc_google_compute_engine_credentials_create(NULL); - if (creds == NULL) { + creds = grpc_google_compute_engine_credentials_create(nullptr); + if (creds == nullptr) { gpr_log(GPR_ERROR, "Could not create gce credentials."); exit(1); } - } else if (json_refresh_token_file_path != NULL) { + } else if (json_refresh_token_file_path != nullptr) { creds = create_refresh_token_creds(json_refresh_token_file_path); - if (creds == NULL) { + if (creds == nullptr) { gpr_log(GPR_ERROR, "Could not create refresh token creds. %s does probably not " "contain a valid json refresh token.", @@ -90,10 +91,10 @@ int main(int argc, char** argv) { gpr_log(GPR_ERROR, "Missing --gce or --json_refresh_token option."); exit(1); } - GPR_ASSERT(creds != NULL); + GPR_ASSERT(creds != nullptr); token = grpc_test_fetch_oauth2_token_with_credentials(creds); - if (token != NULL) { + if (token != nullptr) { printf("Got token: %s.\n", token); gpr_free(token); } |