使用 Duo Security Admin API 创建用户

问题描述 投票:0回答:1

按照 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();
    }
}
java two-factor-authentication google-duo
1个回答
0
投票

在调用 duo admin API 时,您错过了身份验证。 duo admin API 使用 HTTP 基本身份验证来验证请求。使用 Duo 应用程序的集成密钥作为 HTTP 用户名。 Duo Admin api 身份验证

© www.soinside.com 2019 - 2024. All rights reserved.