<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Delete user via API in APIs</title>
    <link>https://community.cisco.com/t5/apis/delete-user-via-api/m-p/4884619#M586</link>
    <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;I’m in the process of writing some code to, via the DUO API, delete users that have left my university and no longer qualify for our license.  In looking over the API, it seems that the logic will be something like this:&lt;BR /&gt;
For every user_id to be deleted&lt;BR /&gt;
For every phone assigned to the user&lt;BR /&gt;
call /admin/v1/phones to find out if there are multiple users for the phone&lt;BR /&gt;
if user_id is the only user of the phone&lt;BR /&gt;
delete phone&lt;BR /&gt;
else&lt;BR /&gt;
call /admin/v1/users/[user_id]/phones/[phone_id] to disassociate the phone from the user&lt;BR /&gt;
*** repeat above For loop for any hardware tokens&lt;BR /&gt;
Delete user&lt;/P&gt;
&lt;P&gt;I was hoping that the delete user API would take care of all of this like the management console does, and also put the user into the trash bin, but alas it doesn’t.  Everything needs to be done in separate tasks.&lt;/P&gt;
&lt;P&gt;Am I on the right track?&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 01 Aug 2018 16:10:58 GMT</pubDate>
    <dc:creator>Todd_Haddaway</dc:creator>
    <dc:date>2018-08-01T16:10:58Z</dc:date>
    <item>
      <title>Delete user via API</title>
      <link>https://community.cisco.com/t5/apis/delete-user-via-api/m-p/4884619#M586</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;I’m in the process of writing some code to, via the DUO API, delete users that have left my university and no longer qualify for our license.  In looking over the API, it seems that the logic will be something like this:&lt;BR /&gt;
For every user_id to be deleted&lt;BR /&gt;
For every phone assigned to the user&lt;BR /&gt;
call /admin/v1/phones to find out if there are multiple users for the phone&lt;BR /&gt;
if user_id is the only user of the phone&lt;BR /&gt;
delete phone&lt;BR /&gt;
else&lt;BR /&gt;
call /admin/v1/users/[user_id]/phones/[phone_id] to disassociate the phone from the user&lt;BR /&gt;
*** repeat above For loop for any hardware tokens&lt;BR /&gt;
Delete user&lt;/P&gt;
&lt;P&gt;I was hoping that the delete user API would take care of all of this like the management console does, and also put the user into the trash bin, but alas it doesn’t.  Everything needs to be done in separate tasks.&lt;/P&gt;
&lt;P&gt;Am I on the right track?&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 01 Aug 2018 16:10:58 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/delete-user-via-api/m-p/4884619#M586</guid>
      <dc:creator>Todd_Haddaway</dc:creator>
      <dc:date>2018-08-01T16:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Delete user via API</title>
      <link>https://community.cisco.com/t5/apis/delete-user-via-api/m-p/4884620#M587</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Hi Todd,&lt;/P&gt;
&lt;P&gt;My name is Andrew and I am a Customer Solutions Engineer with Duo. I often work with universities that are tackling similar account cleanup tasks and you nailed the approach most universities take.&lt;/P&gt;
&lt;P&gt;The process you’ve outlined is a solid approach to removing the users and their phones. From my experience you should be able to remove the user even if they have phones associated with their account. This would let you remove the users that no longer are with your university and then have a separate clean-up function/script that polls for the list of phones. This would do a quick check to see if the ‘user’ array is empty, and if so it can delete the phone. Either way accomplishes the same result, so I would recommend going with the order that makes the most sense to you.&lt;/P&gt;
&lt;P&gt;I also highly recommend using our &lt;A href="https://github.com/duosecurity/duo_client_python"&gt;Duo Client Library&lt;/A&gt; for making the appropriate calls. It really does simplify making the API calls and results in much cleaner scripts overall.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Andrew&lt;/LI&gt;
&lt;/UL&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 01 Aug 2018 20:39:25 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/delete-user-via-api/m-p/4884620#M587</guid>
      <dc:creator>amarrone</dc:creator>
      <dc:date>2018-08-01T20:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Delete user via API</title>
      <link>https://community.cisco.com/t5/apis/delete-user-via-api/m-p/4884621#M588</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Excellent - Thanks Andrew. I appreciate the feedback and link!&lt;/P&gt;
&lt;P&gt;Todd&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 01 Aug 2018 22:46:08 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/delete-user-via-api/m-p/4884621#M588</guid>
      <dc:creator>Todd_Haddaway</dc:creator>
      <dc:date>2018-08-01T22:46:08Z</dc:date>
    </item>
  </channel>
</rss>

