07-24-2018 02:19 PM
I currently have duo 2fa integrated with our custom webapp. I would like to now be able to create a user on our account using the admin api. But I cannot find any documentation that has an example of how to do so.
I can see from the documentation that it’s a post command, but it has no specifics. Can anyone give me an example of that or point me in the right direction?
Thanks you.
-Brian
07-25-2018 12:52 PM
Hello Brian_Fleishman!
The best reference is our Admin API documentation. The API Details section should help you figure it out. Additionally, you may find it useful to look at our API demo clients out on our GitHub, like our Python demo client.
07-25-2018 06:59 PM
I’ve poured through that documentation, but it doesn’t give any examples of an http post. And unfortunately I’m not that familiar with any of the languages that are in the documentation, except for Java.
Do you know of any place where I can see a working example of an http post to create or delete a user? Thanks.
07-26-2018 12:31 PM
Hi Brian,
I was in the same boat just hours ago. I was having issues trying to figure out how to just retrieve a user’s information via the admin API. I’m doing it in PHP, but I’m sure the translation to java would be, hopefully, straight forward:
I created a sample php script that pulled the information for one user (see below). To create a user you would call the “create_user” method that is contained in the Admin.php file. You can see in that function/method its doing a POST. Parameters are found here: Duo Admin API | Duo Security
Sample source code for calling the “users” method of the “Admin” class
<?php
namespace DuoAPI;
include 'Requester.php';
include 'CurlRequester.php';
include 'Client.php';
include 'Admin.php';
$D = new Admin("integration key here","secret key here","api-stuffhere.duosecurity.com");
# just a particular user
# $users = $D->users("smith");
# all users
$users = $D->users();
// Loop through Array
foreach ($users["response"]["response"] as $key => $value) {
print $value["username"] . " " . $value["email"] . " " . $value["realname"] . "\n";
}
?>
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: