Update external_account_credentials.cc

pull/24878/head
Chuan Ren 4 years ago
parent 638c34ceba
commit 04b9780b4e
  1. 19
      src/core/lib/security/credentials/external/external_account_credentials.cc

@ -167,7 +167,16 @@ void ExternalAccountCredentials::OnExchangeTokenInternal(grpc_error* error) {
} else {
if (options_.service_account_impersonation_url.empty()) {
metadata_req_->response = ctx_->response;
metadata_req_->response.body = gpr_strdup(ctx_->response.body);
metadata_req_->response.body = gpr_strdup(
std::string(ctx_->response.body, ctx_->response.body_length).c_str());
metadata_req_->response.hdrs = static_cast<grpc_http_header*>(
gpr_malloc(sizeof(grpc_http_header) * ctx_->response.hdr_count));
for (int i = 0; i < ctx_->response.hdr_count; i++) {
metadata_req_->response.hdrs[i].key =
gpr_strdup(ctx_->response.hdrs[i].key);
metadata_req_->response.hdrs[i].value =
gpr_strdup(ctx_->response.hdrs[i].value);
}
FinishTokenFetch(GRPC_ERROR_NONE);
} else {
ImpersenateServiceAccount();
@ -288,6 +297,14 @@ void ExternalAccountCredentials::OnImpersenateServiceAccountInternal(
metadata_req_->response = ctx_->response;
metadata_req_->response.body = gpr_strdup(body.c_str());
metadata_req_->response.body_length = body.length();
metadata_req_->response.hdrs = static_cast<grpc_http_header*>(
gpr_malloc(sizeof(grpc_http_header) * ctx_->response.hdr_count));
for (int i = 0; i < ctx_->response.hdr_count; i++) {
metadata_req_->response.hdrs[i].key =
gpr_strdup(ctx_->response.hdrs[i].key);
metadata_req_->response.hdrs[i].value =
gpr_strdup(ctx_->response.hdrs[i].value);
}
FinishTokenFetch(GRPC_ERROR_NONE);
}

Loading…
Cancel
Save