Go to the documentation of this file.
40 if (strlen(json_file_path) == 0) {
49 "load_file",
grpc_load_file(json_file_path, 1, &sts_options_slice)));
66 const char* json_refresh_token_file_path) {
78 int main(
int argc,
char** argv) {
80 const char* json_sts_options_file_path =
nullptr;
81 const char* json_refresh_token_file_path =
nullptr;
82 char* token =
nullptr;
86 "File path of the json refresh token.",
87 &json_refresh_token_file_path);
89 cl,
"json_sts_options",
90 "File path of the json sts options. If the path is empty, the program "
91 "will attempt to use the $STS_CREDENTIALS environment variable to access "
92 "a file containing the options.",
93 &json_sts_options_file_path);
96 "Get a token from the GCE metadata server (only works in GCE).",
102 if (json_sts_options_file_path !=
nullptr &&
103 json_refresh_token_file_path !=
nullptr) {
106 "--json_sts_options and --json_refresh_token are mutually exclusive.");
111 if (json_sts_options_file_path !=
nullptr ||
112 json_refresh_token_file_path !=
nullptr) {
114 "Ignoring json refresh token or sts options to get a token from "
115 "the GCE metadata server.");
118 if (creds ==
nullptr) {
122 }
else if (json_refresh_token_file_path !=
nullptr) {
124 if (creds ==
nullptr) {
126 "Could not create refresh token creds. %s does probably not "
127 "contain a valid json refresh token.",
128 json_refresh_token_file_path);
131 }
else if (json_sts_options_file_path !=
nullptr) {
133 if (creds ==
nullptr) {
135 "Could not create sts creds. %s does probably not contain a "
136 "valid json for sts options.",
137 json_sts_options_file_path);
143 "Missing --gce, --json_sts_options, or --json_refresh_token option.");
149 if (token !=
nullptr) {
150 printf(
"Got token: %s.\n", token);
grpc::Status StsCredentialsOptionsFromJson(const std::string &json_string, StsCredentialsOptions *options)
grpc_error_handle grpc_load_file(const char *filename, int add_null_terminator, grpc_slice *output)
grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions *options)
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
GPRAPI void gpr_free(void *ptr)
void gpr_cmdline_destroy(gpr_cmdline *cl)
int main(int argc, char **argv)
GRPCAPI grpc_call_credentials * grpc_google_compute_engine_credentials_create(void *reserved)
GRPCAPI void grpc_call_credentials_release(grpc_call_credentials *creds)
#define GRPC_LOG_IF_ERROR(what, error)
void gpr_cmdline_add_flag(gpr_cmdline *cl, const char *name, const char *help, int *value)
GRPCAPI grpc_call_credentials * grpc_sts_credentials_create(const grpc_sts_credentials_options *options, void *reserved)
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
void gpr_cmdline_add_string(gpr_cmdline *cl, const char *name, const char *help, const char **value)
grpc_sts_credentials_options StsCredentialsCppToCoreOptions(const StsCredentialsOptions &options)
#define GRPC_SLICE_START_PTR(slice)
static grpc_call_credentials * create_sts_creds(const char *json_file_path)
GRPCAPI grpc_call_credentials * grpc_google_refresh_token_credentials_create(const char *json_refresh_token, void *reserved)
gpr_cmdline * gpr_cmdline_create(const char *description)
ABSL_MUST_USE_RESULT bool ok() const
GRPCAPI void grpc_init(void)
GRPCAPI void grpc_shutdown(void)
int gpr_cmdline_parse(gpr_cmdline *cl, int argc, char **argv)
char * grpc_test_fetch_oauth2_token_with_credentials(grpc_call_credentials *creds)
static grpc_call_credentials * create_refresh_token_creds(const char *json_refresh_token_file_path)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:19