任何人都可以帮助我解决我面临的这个错误吗?我对java相当陌生。在这里,我试图在 Duo Admin API 上创建一个用户,但是当我运行这段代码时,我得到了这个
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Base64;
// HTTP basic authentication example in Java using the RTC Server RESTful API
public class Untitled {
public static void main(String[] args) throws IOException, InterruptedException {
// Customer ID
final String customerKey = "key";
// Customer secret
final String customerSecret = "secret";
// Concatenate customer key and customer secret and use base64 to encode the
// concatenated string
String plainCredentials = customerKey + ":" + customerSecret;
String base64Credentials = new String(Base64.getEncoder().encode(plainCredentials.getBytes()));
// Create authorization header
String authorizationHeader = "Basic " + base64Credentials;
HttpClient client = HttpClient.newHttpClient();
// Create HTTP request object
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api-e9770554.duosecurity.com/admin/v1/users")).GET()
.header("Authorization", authorizationHeader).header("Content-Type", "application/json").build();
// Send HTTP request
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
错误
{"code": 40104, "message": "Missing request timestamp", "stat": "FAIL"}