首页 > 解决方案 > 使用 Duo Security Admin API 创建用户

问题描述

我正在关注 Duo Security Admin Api 的此文档:https ://duo.com/docs/adminapi

我正在尝试在我的 ColdFusion webapp 中使用他们的 API 创建/删除用户,但文档仅表明需要使用 post 命令。没有给出示例,我不确定从哪里开始。我假设他们的意思是在提交表单时发布喜欢?但我不确定。

我正在尝试使用以下代码创建用户并删除用户。两者都不起作用,因为我没有看到在我的管理控制台中创建或删除用户。浏览器控制台也没有显示任何信息。

创建用户:

<!--- Create the user in the DuoSecurity Admin API --->
<cfhttp method="post" url="https://api-2fa0b2f8.duosecurity.com/admin/v1/users?username=#get_user.userid#&realname=#get_user.displayName#&email=#get_user.email#" />

删除用户

<!--- Deleted the user in the DuoSecurity Admin API --->
<cfhttp method="delete" url="https://api-2fa0b2f8.duosecurity.com/admin/v1/users/#get_user.userid#" />

如果我将我的 cfhttp 网址粘贴到浏览器中,我会看到以下结果:

{"code": 40401, "message": "Resource not found", "stat": "FAIL"}

我是否还需要以某种方式发送我的应用程序密钥和秘密?

谁能指出我正确的方向?谢谢你。

标签: javascriptcoldfusiontwo-factor-authentication

解决方案


应用程序密钥和秘密 可能需要通过<cfhttpparam>

你正在寻找类似的东西

  <cfhttp method="delete" url="https://api-2fa0b2f8.duosecurity.com/admin/v1/users/#get_user.userid#" />
    <cfhttpparam type = "header" name = "appkey" value = "#appkey#">
    <cfhttpparam type = "header" name = "secret" value = "#secret#">
  </cfhttp>

<cfscript>等价物。


推荐阅读