-u 在 CURL 中意味着什么以及如何 post 使用带 -u 的 restTemplate 的请求

What is the -u means in CURL and how to post a request using restTemplate with -u

我有 cURL

curl -i https://thisIsValidUrl \
 -X PUT \
 -H "Content-Type: application/json" \
 -u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \
 -d '{"email":"customer@example.com","created_at":1361205308,"first_name":"Bob","plan":"basic"}'

我需要 post 使用 spring restTemplate 的请求,但我找不到如何使用 -u

找到了,这只是使用基本身份验证的方法,我应该将 YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE 加密为 Base64 字符串并在 Authorization header

中使用它
    MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>();
    RestTemplate restTemplate = new RestTemplate();

    headers.add("Authorization", "Basic " + Base64String);
    headers.add("Content-Type", "application/json");
    .
    .
    .

    HttpEntity<RaisEventRequest> request = new HttpEntity<RaisEventRequest>(RaisEventRequest, headers);

    ResponseEntity<RaisEventResponse> responseEntity = restTemplate
            .exchange(eventsURL, HttpMethod.POST, request, RaisEventResponse.class);

    return responseEntity.getBody();