static grpc_call_credentials *create_refresh_token_creds( const char *json_refresh_token_file_path) { grpc_slice refresh_token; GPR_ASSERT(GRPC_LOG_IF_ERROR( "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); }
static grpc_call_credentials *create_refresh_token_creds( const char *json_refresh_token_file_path) { int success; gpr_slice refresh_token = gpr_load_file(json_refresh_token_file_path, 1, &success); if (!success) { gpr_log(GPR_ERROR, "Could not read file %s.", json_refresh_token_file_path); exit(1); } return grpc_google_refresh_token_credentials_create( (const char *)GPR_SLICE_START_PTR(refresh_token), NULL); }
CallCredentials *pygrpc_CallCredentials_refresh_token( PyTypeObject *type, PyObject *args, PyObject *kwargs) { CallCredentials *self; const char *json_refresh_token; static char *keywords[] = {"json_refresh_token", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:refresh_token", keywords, &json_refresh_token)) { return NULL; } self = (CallCredentials *)type->tp_alloc(type, 0); self->c_creds = grpc_google_refresh_token_credentials_create(json_refresh_token, NULL); if (!self->c_creds) { Py_DECREF(self); PyErr_SetString(PyExc_RuntimeError, "couldn't create credentials from refresh token"); return NULL; } return self; }