<?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 Re: API check works but Auth call does not in postman in APIs</title>
    <link>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884975#M632</link>
    <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Hi &lt;A class="mention" href="https://community.duo.com/u/duopablo"&gt;@DuoPablo&lt;/A&gt; - I was sending the post data as JSON body instead of as parameters. Sending as params resolves it.&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 20 Jan 2023 19:36:43 GMT</pubDate>
    <dc:creator>Ravi_Akkiraju</dc:creator>
    <dc:date>2023-01-20T19:36:43Z</dc:date>
    <item>
      <title>API check works but Auth call does not in postman</title>
      <link>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884971#M628</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;I extensively looked at various threads but does not help the problem I am facing. I am using the pre-request script (thanks to this community). Was able to get the /auth/v2/check API work properly.&lt;/P&gt;
&lt;H3&gt;
&lt;A name="pre-request-script-in-postman-1" class="anchor" href="#pre-request-script-in-postman-1"&gt;&lt;/A&gt;Pre-Request Script in PostMan:&lt;/H3&gt;
&lt;P&gt;function getAuthHeader(httpMethod, requestUrl, requestBody) { console.log(requestBody); //body data console.log(httpMethod); // http type: POST, GET, ETC&lt;/P&gt;
&lt;P&gt;var CLIENT_KEY = ‘MY_INTEGRATION_KEY’;&lt;/P&gt;
&lt;P&gt;var SECRET_KEY = ‘MY_SECRET_KEY’;&lt;/P&gt;
&lt;P&gt;var AUTH_TYPE = ‘HMAC-SHA1’;&lt;/P&gt;
&lt;P&gt;var moment = require(‘moment’)&lt;/P&gt;
&lt;P&gt;/* Uncomment out lines below to use your test for getting correct formatted time and date */&lt;/P&gt;
&lt;P&gt;var timestamp = moment().format(“ddd, DD MMM YYYY HH:mm:ss ZZ”);&lt;/P&gt;
&lt;P&gt;pm.environment.set(“timestampHeader”,timestamp);&lt;/P&gt;
&lt;P&gt;//var timestamp = “Tue, 21 Aug 2012 17:29:18 -0000”; /* Only for example */&lt;/P&gt;
&lt;P&gt;pm.environment.set(“timestampHeader”,timestamp);&lt;/P&gt;
&lt;P&gt;var hostname = “{mypresetURL}.duosecurity.com”;&lt;/P&gt;
&lt;P&gt;var apicall = “/auth/v2/check”&lt;/P&gt;
&lt;P&gt;var body = “”;&lt;/P&gt;
&lt;P&gt;var requestData = timestamp +“\n”+“GET”+“\n”+hostname+“\n”+apicall+“\n”+body;&lt;/P&gt;
&lt;P&gt;console.log(requestData);&lt;/P&gt;
&lt;P&gt;var hmacDigest = CryptoJS.HmacSHA1(requestData, SECRET_KEY);&lt;/P&gt;
&lt;P&gt;console.log(hmacDigest);&lt;/P&gt;
&lt;P&gt;var prebase = CLIENT_KEY+“:”+hmacDigest;&lt;/P&gt;
&lt;P&gt;console.log(prebase);&lt;/P&gt;
&lt;P&gt;var baseComplete = btoa(prebase);&lt;/P&gt;
&lt;P&gt;console.log(baseComplete);&lt;/P&gt;
&lt;P&gt;var authHeader = "Basic "+baseComplete;&lt;/P&gt;
&lt;P&gt;return authHeader;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;postman.setEnvironmentVariable(‘hmacAuthHeader’, getAuthHeader(request[‘method’], request[‘url’], request[‘data’]));&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;Duo Response:&lt;BR /&gt;
{&lt;BR /&gt;
“response”: {&lt;BR /&gt;
“time”: 1673984145&lt;BR /&gt;
},&lt;BR /&gt;
“stat”: “OK”&lt;BR /&gt;
}&lt;/P&gt;
&lt;H3&gt;
&lt;A name="now-when-i-use-the-below-script-to-post-an-auth-api-call-for-a-specific-user-i-get-an-error-pre-request-script-2" class="anchor" href="#now-when-i-use-the-below-script-to-post-an-auth-api-call-for-a-specific-user-i-get-an-error-pre-request-script-2"&gt;&lt;/A&gt;Now when I use the below script to post an Auth API call for a specific user, I get an error.&lt;BR /&gt;
Pre-Request Script:&lt;/H3&gt;
&lt;P&gt;function getAuthHeader(httpMethod, requestUrl, requestBody) { console.log(requestBody); //body data console.log(httpMethod); // http type: POST, GET, ETC&lt;/P&gt;
&lt;P&gt;var CLIENT_KEY = ‘MY_INTEGRATION_KEY’;&lt;/P&gt;
&lt;P&gt;var SECRET_KEY = ‘MY_SECRET_KEY’;&lt;/P&gt;
&lt;P&gt;var AUTH_TYPE = ‘HMAC-SHA1’;&lt;/P&gt;
&lt;P&gt;var moment = require(‘moment’)&lt;/P&gt;
&lt;P&gt;/* Uncomment out lines below to use your test for getting correct formatted time and date */&lt;/P&gt;
&lt;P&gt;var timestamp = moment().format(“ddd, DD MMM YYYY HH:mm:ss ZZ”);&lt;/P&gt;
&lt;P&gt;pm.environment.set(“timestampHeader”,timestamp);&lt;/P&gt;
&lt;P&gt;//var timestamp = “Tue, 21 Aug 2012 17:29:18 -0000”; /* Only for example */&lt;/P&gt;
&lt;P&gt;pm.environment.set(“timestampHeader”,timestamp);&lt;/P&gt;
&lt;P&gt;var hostname = “{myURL}.duosecurity.com”;&lt;/P&gt;
&lt;P&gt;var apicall = “/auth/v2/auth”;&lt;/P&gt;
&lt;P&gt;var body = ‘{"username": "bbanner","factor": "push","async": "false"}’;&lt;/P&gt;
&lt;P&gt;var requestData = timestamp +“\n”+“POST”+“\n”+hostname+“\n”+apicall+“\n”+body;&lt;/P&gt;
&lt;P&gt;console.log(requestData);&lt;/P&gt;
&lt;P&gt;var hmacDigest = CryptoJS.HmacSHA1(requestData, SECRET_KEY);&lt;/P&gt;
&lt;P&gt;console.log(hmacDigest);&lt;/P&gt;
&lt;P&gt;var prebase = CLIENT_KEY+“:”+hmacDigest;&lt;/P&gt;
&lt;P&gt;console.log(prebase);&lt;/P&gt;
&lt;P&gt;var baseComplete = btoa(prebase);&lt;/P&gt;
&lt;P&gt;console.log(baseComplete);&lt;/P&gt;
&lt;P&gt;var authHeader = "Basic "+baseComplete;&lt;/P&gt;
&lt;P&gt;return authHeader;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;H3&gt;
&lt;A name="postmansetenvironmentvariablehmacauthheader-getauthheaderrequestmethod-requesturl-requestdata-3" class="anchor" href="#postmansetenvironmentvariablehmacauthheader-getauthheaderrequestmethod-requesturl-requestdata-3"&gt;&lt;/A&gt;postman.setEnvironmentVariable(‘hmacAuthHeader’, getAuthHeader(request[‘method’], request[‘url’], request[‘data’]));&lt;/H3&gt;
&lt;P&gt;Duo response:&lt;BR /&gt;
{&lt;BR /&gt;
“code”: 40103,&lt;BR /&gt;
“message”: “Invalid signature in request credentials”,&lt;BR /&gt;
“stat”: “FAIL”&lt;BR /&gt;
}&lt;/P&gt;
&lt;P&gt;Thank you for your help in advance.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Jan 2023 19:51:14 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884971#M628</guid>
      <dc:creator>Ravi_Akkiraju</dc:creator>
      <dc:date>2023-01-17T19:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: API check works but Auth call does not in postman</title>
      <link>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884972#M629</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;I think the request data will change for the Auth POST API. Let me try that first and will update this post.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Jan 2023 20:56:00 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884972#M629</guid>
      <dc:creator>Ravi_Akkiraju</dc:creator>
      <dc:date>2023-01-17T20:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: API check works but Auth call does not in postman</title>
      <link>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884973#M630</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Updated the request data for the Auth API POST. Still the same issue.&lt;/P&gt;
&lt;P&gt;var requestData =  timestamp +“\n”+“POST”+“\n”+hostname+“\n”+apicall+“\n”+ “factor=push&amp;amp;username=bbanner&amp;amp;”;&lt;/P&gt;
&lt;H3&gt;
&lt;A name="postman-console-has-this-as-the-request-string-1" class="anchor" href="#postman-console-has-this-as-the-request-string-1"&gt;&lt;/A&gt;Postman console has this as the request String.&lt;/H3&gt;
&lt;H3&gt;
&lt;A name="tue-17-jan-2023-162859-0500-post-authv2auth-factorpushusernamebbanner-2" class="anchor" href="#tue-17-jan-2023-162859-0500-post-authv2auth-factorpushusernamebbanner-2"&gt;&lt;/A&gt;Tue, 17 Jan 2023 16:28:59 -0500&lt;BR /&gt;
POST&lt;BR /&gt;
&lt;A href="http://api-ecdb9c55.duosecurity.com" rel="noopener nofollow ugc"&gt;■■■■■■■■■■■■■■■■■■■■■■■■■■■■&lt;/A&gt;&lt;BR /&gt;
/auth/v2/auth&lt;BR /&gt;
factor=push&amp;amp;username=bbanner&lt;/H3&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Jan 2023 21:06:09 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884973#M630</guid>
      <dc:creator>Ravi_Akkiraju</dc:creator>
      <dc:date>2023-01-17T21:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: API check works but Auth call does not in postman</title>
      <link>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884974#M631</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Hi &lt;A class="mention" href="https://community.duo.com/u/ravi_akkiraju"&gt;@Ravi_Akkiraju&lt;/A&gt; ,&lt;/P&gt;
&lt;P&gt;Please note that the &lt;CODE&gt;device&lt;/CODE&gt; parameter is required when using Push as the factor (&lt;A href="https://duo.com/docs/authapi#/auth" class="inline-onebox" rel="noopener nofollow ugc"&gt;Duo Auth API | Duo Security&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;DIV class="lightbox-wrapper"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="2X_b_b53964b9098bf8f8c5de6b7a816539a9394d9b86.png" style="width: 690px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/191092i1004602D829B7E08/image-size/large?v=v2&amp;amp;px=999" role="button" title="2X_b_b53964b9098bf8f8c5de6b7a816539a9394d9b86.png" alt="2X_b_b53964b9098bf8f8c5de6b7a816539a9394d9b86.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;You might try the pre-request script from &lt;A href="https://community.duo.com/t/preauth-api-failing-but-check-and-ping-are-good/3125/17"&gt;this post&lt;/A&gt; as it does not need to be modified when using POST instead of GET requests. It works when using:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;var requestData =  timestamp+"\n"+httpMethod+"\n"+API_HOSTNAME+"\n"+api_call+"\n"+encoded_params;
console.log(requestData);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use &lt;CODE&gt;POST https://1234abcd.duosecurity.com/auth/v2/auth?username=bbanner&amp;amp;factor=push&amp;amp;device=auto&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 19 Jan 2023 18:04:18 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884974#M631</guid>
      <dc:creator>DuoPablo</dc:creator>
      <dc:date>2023-01-19T18:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: API check works but Auth call does not in postman</title>
      <link>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884975#M632</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Hi &lt;A class="mention" href="https://community.duo.com/u/duopablo"&gt;@DuoPablo&lt;/A&gt; - I was sending the post data as JSON body instead of as parameters. Sending as params resolves it.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 20 Jan 2023 19:36:43 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/api-check-works-but-auth-call-does-not-in-postman/m-p/4884975#M632</guid>
      <dc:creator>Ravi_Akkiraju</dc:creator>
      <dc:date>2023-01-20T19:36:43Z</dc:date>
    </item>
  </channel>
</rss>

