Basic auth is the authorization header.
You should add this header with a value consisting of "base" (note the space) and your username: pass (separated by a colon), encoded in base64. It is safe if you use HTTPS.
Here is how I do it in vert.x:
HttpClient client = vertx.createHttpClient().setSSL(true)
.setTrustAll(true)
.setHost("api.myawesomeapi.com")
.setPort(443);
HttpClientRequest clientRequest = client.get("/"+action+"/?"+params, new Handler<HttpClientResponse>() {
public void handle(final HttpClientResponse response) {
if (response.statusCode==200){
} else {
}
}
});
clientRequest.putHeader(HttpHeaders.Names.AUTHORIZATION, "Basic "+base64key);
base64key, , - :
base64key = Base64.encodeBytes(new StringBuilder(apiKey).append(":").append(secretKey).toString().getBytes(), Base64.DONT_BREAK_LINES);
POST get, :
clientRequest.putHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(params.getBytes().length))
.putHeader(HttpHeaders.Names.CONTENT_TYPE, "application/x-www-form-urlencoded")
.write(params);
,