<?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 DUO API - Code 40101 Missing Request Credentials - Powershell in APIs</title>
    <link>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882498#M447</link>
    <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Would anybody be able to help me out here? Having problems connecting to the DUO api in powershell, i think it is to do with the headers but cannot figure out what is wrong???&lt;/P&gt;
&lt;P&gt;function ConvertTo-Base64($string)&lt;BR /&gt;
{&lt;BR /&gt;
$bytes = [System.Text.Encoding]::UTF8.GetBytes($string);&lt;BR /&gt;
$encoded = [System.Convert]::ToBase64String($bytes);&lt;BR /&gt;
return $encoded;&lt;BR /&gt;
}&lt;/P&gt;
&lt;P&gt;$intKey = “integrationkey”&lt;/P&gt;
&lt;P&gt;$sKey = “secretkey”&lt;/P&gt;
&lt;P&gt;$hostname = “hostname”&lt;/P&gt;
&lt;P&gt;$path = “/auth/v2/check”&lt;/P&gt;
&lt;P&gt;$params = $null&lt;/P&gt;
&lt;P&gt;$method = “GET”&lt;/P&gt;
&lt;P&gt;$contentType = “application/x-www-form-urlencoded”&lt;/P&gt;
&lt;P&gt;$day = (get-date).day&lt;BR /&gt;
$dayAbr = (get-date).DayOfWeek.ToString().Substring(0,3)&lt;BR /&gt;
$month = (get-date).Month&lt;BR /&gt;
$monthAbr =  (Get-Culture).DateTimeFormat.GetAbbreviatedMonthName($month)&lt;BR /&gt;
$year = (get-date).Year&lt;BR /&gt;
$time = (get-date).TimeOfDay&lt;/P&gt;
&lt;P&gt;[string]$date = $dayAbr + “, " + $day + " " + $monthAbr + " " + $year + " " + $time.Hours + “:” + $time.Minutes + “:” + $time.Seconds + " -0000”&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="math"&gt;message = &lt;/SPAN&gt;($date + “&lt;CODE&gt;n" + $method + "&lt;/CODE&gt;n” + $hostname + “&lt;CODE&gt;n" + $path + "&lt;/CODE&gt;n”)&lt;BR /&gt;
$secret = $sKey&lt;/P&gt;
&lt;P&gt;$hmacsha = New-Object System.Security.Cryptography.HMACSHA256&lt;BR /&gt;
$hmacsha.key = [Text.Encoding]::ASCII.GetBytes($secret)&lt;BR /&gt;
$signature = $hmacsha.ComputeHash([Text.Encoding]::ASCII.GetBytes($message))&lt;BR /&gt;
$signature = [Convert]::ToBase64String($signature)&lt;/P&gt;
&lt;P&gt;$b64 = ConvertTo-Base64($intKey + “:” + $signature);&lt;BR /&gt;
$auth = "Basic " + $signature;&lt;/P&gt;
&lt;P&gt;$headers = @{}&lt;BR /&gt;
$headers.Add(“Date”, $date)&lt;BR /&gt;
$headers.Add(“Authorization”, $auth)&lt;BR /&gt;
$headers.Add(“Host”, $hostname)&lt;BR /&gt;
$headers.Add(“Content-Length”, “35”)&lt;BR /&gt;
$headers.Add(“Content-Type”, $contentType)&lt;/P&gt;
&lt;P&gt;Invoke-WebRequest -Uri $(“https://” + $hostname + $command) -Headers $headers&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 22 Jan 2019 15:02:04 GMT</pubDate>
    <dc:creator>kieron25</dc:creator>
    <dc:date>2019-01-22T15:02:04Z</dc:date>
    <item>
      <title>DUO API - Code 40101 Missing Request Credentials - Powershell</title>
      <link>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882498#M447</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Would anybody be able to help me out here? Having problems connecting to the DUO api in powershell, i think it is to do with the headers but cannot figure out what is wrong???&lt;/P&gt;
&lt;P&gt;function ConvertTo-Base64($string)&lt;BR /&gt;
{&lt;BR /&gt;
$bytes = [System.Text.Encoding]::UTF8.GetBytes($string);&lt;BR /&gt;
$encoded = [System.Convert]::ToBase64String($bytes);&lt;BR /&gt;
return $encoded;&lt;BR /&gt;
}&lt;/P&gt;
&lt;P&gt;$intKey = “integrationkey”&lt;/P&gt;
&lt;P&gt;$sKey = “secretkey”&lt;/P&gt;
&lt;P&gt;$hostname = “hostname”&lt;/P&gt;
&lt;P&gt;$path = “/auth/v2/check”&lt;/P&gt;
&lt;P&gt;$params = $null&lt;/P&gt;
&lt;P&gt;$method = “GET”&lt;/P&gt;
&lt;P&gt;$contentType = “application/x-www-form-urlencoded”&lt;/P&gt;
&lt;P&gt;$day = (get-date).day&lt;BR /&gt;
$dayAbr = (get-date).DayOfWeek.ToString().Substring(0,3)&lt;BR /&gt;
$month = (get-date).Month&lt;BR /&gt;
$monthAbr =  (Get-Culture).DateTimeFormat.GetAbbreviatedMonthName($month)&lt;BR /&gt;
$year = (get-date).Year&lt;BR /&gt;
$time = (get-date).TimeOfDay&lt;/P&gt;
&lt;P&gt;[string]$date = $dayAbr + “, " + $day + " " + $monthAbr + " " + $year + " " + $time.Hours + “:” + $time.Minutes + “:” + $time.Seconds + " -0000”&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="math"&gt;message = &lt;/SPAN&gt;($date + “&lt;CODE&gt;n" + $method + "&lt;/CODE&gt;n” + $hostname + “&lt;CODE&gt;n" + $path + "&lt;/CODE&gt;n”)&lt;BR /&gt;
$secret = $sKey&lt;/P&gt;
&lt;P&gt;$hmacsha = New-Object System.Security.Cryptography.HMACSHA256&lt;BR /&gt;
$hmacsha.key = [Text.Encoding]::ASCII.GetBytes($secret)&lt;BR /&gt;
$signature = $hmacsha.ComputeHash([Text.Encoding]::ASCII.GetBytes($message))&lt;BR /&gt;
$signature = [Convert]::ToBase64String($signature)&lt;/P&gt;
&lt;P&gt;$b64 = ConvertTo-Base64($intKey + “:” + $signature);&lt;BR /&gt;
$auth = "Basic " + $signature;&lt;/P&gt;
&lt;P&gt;$headers = @{}&lt;BR /&gt;
$headers.Add(“Date”, $date)&lt;BR /&gt;
$headers.Add(“Authorization”, $auth)&lt;BR /&gt;
$headers.Add(“Host”, $hostname)&lt;BR /&gt;
$headers.Add(“Content-Length”, “35”)&lt;BR /&gt;
$headers.Add(“Content-Type”, $contentType)&lt;/P&gt;
&lt;P&gt;Invoke-WebRequest -Uri $(“https://” + $hostname + $command) -Headers $headers&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 22 Jan 2019 15:02:04 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882498#M447</guid>
      <dc:creator>kieron25</dc:creator>
      <dc:date>2019-01-22T15:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: DUO API - Code 40101 Missing Request Credentials - Powershell</title>
      <link>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882499#M448</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Check out this function I created that will create a properly formatted request&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;https://github.com/StarkCaptain/duo/blob/master/scripts/new-duoRequest.ps1&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;$Request = New-DuoRequest -apiHost ‘&lt;A href="http://api-nnnnn.duosecurity.com" rel="nofollow noopener"&gt;■■■■&lt;/A&gt;’ -apiEndpoint ‘/admin/v1/users’ -apiKey ‘nnnnn’ -apiSecret ‘nnnnn’&lt;/P&gt;
&lt;P&gt;Invoke-RestMethod &lt;SPAN class="mention"&gt;@Request&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Its forked from the below module, however I didn’t prefer how the author assumes certain things about how you store the api secret so I re-wrote it a bit.&lt;/P&gt;
&lt;ASIDE class="onebox whitelistedgeneric"&gt;
  &lt;HEADER class="source"&gt;
      &lt;IMG src="https://github.githubassets.com/favicon.ico" class="site-icon" width="32" height="32" /&gt;
      &lt;A href="https://github.com/PWSHNinja/PSDuo" target="_blank" rel="nofollow noopener"&gt;GitHub&lt;/A&gt;
  &lt;/HEADER&gt;
  &lt;ARTICLE class="onebox-body"&gt;
    &lt;span class="lia-inline-image-display-wrapper" image-alt="1X_fa292e1260233032c89fb9aa0aeb61a39f459fe0.png" style="width: 420px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/190954i00C04B87632A5538/image-size/large?v=v2&amp;amp;px=999" role="button" title="1X_fa292e1260233032c89fb9aa0aeb61a39f459fe0.png" alt="1X_fa292e1260233032c89fb9aa0aeb61a39f459fe0.png" /&gt;&lt;/span&gt;

&lt;H3&gt;&lt;A href="https://github.com/PWSHNinja/PSDuo" target="_blank" rel="nofollow noopener"&gt;PWSHNinja/PSDuo&lt;/A&gt;&lt;/H3&gt;

&lt;P&gt;A Powershell module to handle DUO Auth functions. Contribute to PWSHNinja/PSDuo development by creating an account on GitHub.&lt;/P&gt;


  &lt;/ARTICLE&gt;
  &lt;DIV class="onebox-metadata"&gt;
    
    
  &lt;/DIV&gt;
  &lt;DIV style="clear: both"&gt;&lt;/DIV&gt;
&lt;/ASIDE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Apr 2019 21:50:37 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882499#M448</guid>
      <dc:creator>Toto_Tamberine</dc:creator>
      <dc:date>2019-04-18T21:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: DUO API - Code 40101 Missing Request Credentials - Powershell</title>
      <link>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882500#M449</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;I tried the module but i get this error. Verified the integration Key and secret key. Is there something I am missing?&lt;/P&gt;
&lt;P&gt;Invoke-RestMethod : {“code”: 40102, “message”: “Invalid integration key in request credentials”, “stat”: “FAIL”}&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 Mar 2020 19:54:55 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882500#M449</guid>
      <dc:creator>fwilson</dc:creator>
      <dc:date>2020-03-13T19:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: DUO API - Code 40101 Missing Request Credentials - Powershell</title>
      <link>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882501#M450</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;I am still using that powershell function as is today. Do you have the admin api application setup with the necessary API permissions based on the api endpoints you want to use?&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 14 Mar 2020 02:21:41 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882501#M450</guid>
      <dc:creator>Toto_Tamberine</dc:creator>
      <dc:date>2020-03-14T02:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: DUO API - Code 40101 Missing Request Credentials - Powershell</title>
      <link>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882502#M451</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;I believe I do but I am new to DUO so is there anything I should look for?&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Mar 2020 16:26:31 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882502#M451</guid>
      <dc:creator>fwilson</dc:creator>
      <dc:date>2020-03-16T16:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: DUO API - Code 40101 Missing Request Credentials - Powershell</title>
      <link>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882503#M452</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Hi This is Yuri&lt;/P&gt;
&lt;P&gt;do you know how to call api with powershell?&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 16 Jul 2020 08:37:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882503#M452</guid>
      <dc:creator>kabuchan15</dc:creator>
      <dc:date>2020-07-16T08:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: DUO API - Code 40101 Missing Request Credentials - Powershell</title>
      <link>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882504#M453</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;ASIDE class="quote no-group" data-username="kieron25" data-post="1" data-topic="3880"&gt;
&lt;DIV class="title"&gt;
&lt;DIV class="quote-controls"&gt;&lt;/DIV&gt;
&lt;IMG width="20" height="20" src="https://community.cisco.com/legacyfs/online/ciscoduo/letters/k_b5e925.png" style="display : inline;" /&gt; kieron25:&lt;/DIV&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Would anybody be able to help me out here? Having problems connecting to the DUO api in powershell, i think it is to do with the headers but cannot figure out what is wrong???&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/ASIDE&gt;
&lt;P&gt;what is message = ($date + “n" + $method + “n” + $hostname + “n” + $path + "n”)&lt;BR /&gt;
$secret = $sKey&lt;/P&gt;
&lt;P&gt;$hmacsha = New-Object System.Security.Cryptography.HMACSHA256&lt;BR /&gt;
$hmacsha.key = [Text.Encoding]::ASCII.GetBytes($secret)&lt;BR /&gt;
$signature = $hmacsha.ComputeHash([Text.Encoding]::ASCII.GetBytes($message))&lt;BR /&gt;
$signature = [Convert]::ToBase64String($signature)&lt;/P&gt;
&lt;P&gt;$b64 = ConvertTo-Base64($intKey + “:” + $signature);&lt;BR /&gt;
$auth = "Basic " + $signature;?? do we still need?&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 30 Jul 2020 00:43:59 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882504#M453</guid>
      <dc:creator>kabuchan15</dc:creator>
      <dc:date>2020-07-30T00:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: DUO API - Code 40101 Missing Request Credentials - Powershell</title>
      <link>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882505#M454</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;ASIDE class="quote no-group quote-modified" data-username="Toto_Tamberine" data-post="2" data-topic="3880"&gt;
&lt;DIV class="title"&gt;
&lt;DIV class="quote-controls"&gt;&lt;/DIV&gt;
&lt;IMG width="20" height="20" src="https://community.cisco.com/legacyfs/online/ciscoduo/avatar_quotes/toto_tamberine.png" style="display : inline;" /&gt; Toto_Tamberine:&lt;/DIV&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="https://github.com/StarkCaptain/duo/blob/master/scripts/new-duoRequest.ps1" class="inline-onebox" rel="noopener nofollow ugc"&gt;duo/new-duoRequest.ps1 at master · StarkCaptain/duo · GitHub&lt;/A&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/ASIDE&gt;
&lt;P&gt;Just want to verify that this function  worked for me.  You can test it by calling the function as described in the comments at the top.   Thanks! — L&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 14 Apr 2021 16:59:51 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/duo-api-code-40101-missing-request-credentials-powershell/m-p/4882505#M454</guid>
      <dc:creator>lkeyes1</dc:creator>
      <dc:date>2021-04-14T16:59:51Z</dc:date>
    </item>
  </channel>
</rss>

