按照Duo Security Admin API的文档,我正在尝试创建/删除用户。该文档仅表明需要使用 post 命令。没有给出示例,我不确定从哪里开始。
我正在尝试使用以下代码创建用户并删除用户。两者都不起作用,因为我没有看到在我的管理控制台中创建或删除用户。
{"code": 40101, "message": "Missing request credentials", "stat": "FAIL"}
当我粘贴我的 URL 时,我收到此错误并且未创建用户。我究竟做错了什么?
import java.io.*;
import java.net.URL;
import java.net.HttpURLConnection;
public class duo {
public static void main(String[] args) throws IOException, InterruptedException {
// Create a neat value object to hold the URL
URL url;
url = new URL("https://api-e9770554.duosecurity.com/admin/v1/users");
// Open a connection(?) on the URL(??) and cast the response(???)
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Now it's "open", we can set the request method, headers etc.
connection.setRequestProperty("accept", "application/json");
// This line makes the request
InputStream responseStream = connection.getInputStream();
}
}