<?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: Mandatory Request Headers for Redlock API - x-redlock-auth in Prisma Cloud Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/331533#M273</link>
    <description>&lt;P&gt;Where do you get the value of "CustomerName" in the request to get the JWT?&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jun 2020 23:05:44 GMT</pubDate>
    <dc:creator>Sly_Cooper</dc:creator>
    <dc:date>2020-06-03T23:05:44Z</dc:date>
    <item>
      <title>Mandatory Request Headers for Redlock API - x-redlock-auth</title>
      <link>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/259433#M128</link>
      <description>&lt;P&gt;Hi- I'm trying to use the API with Python and am having some trouble getting authorized to obtain data using the x-redlock-auth request header.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, let me add the disclaimer that I'm no Python expert so the help is appreciated even if it seems basic. I also understand that PAN/ Redlock isn't here to teach us how to code but I'm looking for an API doc example at a minimum which seems reasonable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW: the API documentation is great and it's cool that there are code examples!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That said, I'm left wondering about using the Python requests module and how to state the&amp;nbsp;x-redlock-auth mandatory request header.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The docs say that the x-redlock-auth and Content-Type are mandatory. I can successfully declare&amp;nbsp;declare content type as&amp;nbsp;&lt;SPAN&gt;application/json using standard Python response module code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm also able to get my JWT and&lt;SPAN&gt;I can define the content type ok as I can get my JWT and parse into a variable from the successful JSON response.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I don't see example code to use x-redlock-auth in the request header.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I&lt;/SPAN&gt;n the examples there is a pop-up for x-redlock-auth prompting for the JWT but the code example doesn't refelct how to use in the params statement of the requests module.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example code snippet from the REST API Doc's - generated using the the query params.&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="code snippet from Redlock REST API docs" style="width: 668px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/19794i75E160F93C0DA11A/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Live Community - New Message - Live Community 2019-05-01 10-37-28.jpg" alt="code snippet from Redlock REST API docs" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;code snippet from Redlock REST API docs&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Can anyone provide an example of defining the headers for the required&amp;nbsp; x-redlock-auth mandatory request headers in the context of this?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks for any help! Would love to automate Redlock login monitoring into a security validation workflow at my organization.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 17:51:33 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/259433#M128</guid>
      <dc:creator>TobyBarber</dc:creator>
      <dc:date>2020-09-02T17:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Mandatory Request Headers for Redlock API - x-redlock-auth</title>
      <link>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/260253#M129</link>
      <description>&lt;P&gt;This is how I'm logging in to the API and setting up headers for subsequent requests using Python.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# Configuration&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;REDLOCK_API_URL&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;A href="https://api.redlock.io" target="_blank" rel="noopener"&gt;https://api.redlock.io&lt;/A&gt;'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;REDLOCK_CUSTOMER_NAME&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;'example.com'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;REDLOCK_USER_NAME&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;'joe.smith@example.com'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;redlock_api_headers &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; { &lt;/SPAN&gt;&lt;SPAN&gt;'Content-Type'&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;'application/json'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'x-redlock-auth'&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;''&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'cache-control'&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;'no-cache'&lt;/SPAN&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;redlock_password &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; getpass.getpass(&lt;/SPAN&gt;&lt;SPAN&gt;"Enter RedLock password for &lt;/SPAN&gt;&lt;SPAN&gt;{}&lt;/SPAN&gt;&lt;SPAN&gt;: "&lt;/SPAN&gt;&lt;SPAN&gt;.format(&lt;/SPAN&gt;&lt;SPAN&gt;REDLOCK_USER_NAME&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# login to RedLock API&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;redlock_api_payload_login &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'username'&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;REDLOCK_USER_NAME&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'customerName'&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;REDLOCK_CUSTOMER_NAME&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'password'&lt;/SPAN&gt;&lt;SPAN&gt;: redlock_password&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;request_url &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;{}&lt;/SPAN&gt;&lt;SPAN&gt;/login'&lt;/SPAN&gt;&lt;SPAN&gt;.format(&lt;/SPAN&gt;&lt;SPAN&gt;REDLOCK_API_URL&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;response &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; requests.request(&lt;/SPAN&gt;&lt;SPAN&gt;"POST"&lt;/SPAN&gt;&lt;SPAN&gt;, request_url, data&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;json.dumps(redlock_api_payload_login), headers&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;redlock_api_headers)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;redlock_api_headers[&lt;/SPAN&gt;&lt;SPAN&gt;'x-redlock-auth'&lt;/SPAN&gt;&lt;SPAN&gt;] &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; json.loads(response.text)[&lt;/SPAN&gt;&lt;SPAN&gt;'token'&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 08 May 2019 11:58:21 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/260253#M129</guid>
      <dc:creator>JBruce2</dc:creator>
      <dc:date>2019-05-08T11:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Mandatory Request Headers for Redlock API - x-redlock-auth</title>
      <link>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/260310#M130</link>
      <description>&lt;P&gt;A similar alternative to the above:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import requests
import json

def login()
    header = {'Content-Type':'application/json'}
    payload = {'username':'redlock_user','password':'redlock_pw','customerName':'customer_name'}
    API = 'https://api.redlock.io'

    response = requests.request('POST', '{}/login'.format(API), json=payload, headers=header)

    json_response = response.json()

    return json_response['token']

JWT_TOKEN = login()

REQ_HEADER = {'Content-Type':'application/json','x-redlock-auth':JWT_TOKEN}

# Example data pull
response = requests.request('GET', '{}/cloud'.format(API), headers=REQ_HEADER)

cloud_accounts = json.loads(response.text)&lt;/PRE&gt;&lt;P&gt;That small code snippet should load all cloud account instances in RedLock and save them to an array cloud_accounts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 03:55:12 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/260310#M130</guid>
      <dc:creator>JBox</dc:creator>
      <dc:date>2019-05-09T03:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Mandatory Request Headers for Redlock API - x-redlock-auth</title>
      <link>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/260313#M131</link>
      <description>&lt;P&gt;Thanks for the response. I didn't get to testing for my use case but looks to make sense with the headers definition for 'x-redlock-auth' being passed to reqests. Will mark as a solution when I get to testing.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 04:18:51 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/260313#M131</guid>
      <dc:creator>TobyBarber</dc:creator>
      <dc:date>2019-05-09T04:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Mandatory Request Headers for Redlock API - x-redlock-auth</title>
      <link>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/260314#M132</link>
      <description>&lt;P&gt;Thanks for another approach. I didn't get to testing for my use case but looks to make sense with the headers definition for 'x-redlock-auth' being passed to reqests. Will mark as a solution when I get to testing.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 04:19:34 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/260314#M132</guid>
      <dc:creator>TobyBarber</dc:creator>
      <dc:date>2019-05-09T04:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Mandatory Request Headers for Redlock API - x-redlock-auth</title>
      <link>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/260788#M133</link>
      <description>Hi JBox- Thanks again, this helped for sure and I liked the function so it can be used later in the script. Couple notes for others on what I did to get it to work for me. First the API variable didn't carry over outside the user defined function on my system so I just defined another variable outside that block to get it to go for me and called that in the requests function call. Second, I think the def login() in the example needed a : after the definition of the user function. It looked like, login(): and that worked on my system. It's probably a janky way to do it but again, I'm not great at this. Either way thanks for for helping with that definition of the x-redlock-auth JWT handling!</description>
      <pubDate>Mon, 13 May 2019 17:02:39 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/260788#M133</guid>
      <dc:creator>TobyBarber</dc:creator>
      <dc:date>2019-05-13T17:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Mandatory Request Headers for Redlock API - x-redlock-auth</title>
      <link>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/331533#M273</link>
      <description>&lt;P&gt;Where do you get the value of "CustomerName" in the request to get the JWT?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2020 23:05:44 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/331533#M273</guid>
      <dc:creator>Sly_Cooper</dc:creator>
      <dc:date>2020-06-03T23:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Mandatory Request Headers for Redlock API - x-redlock-auth</title>
      <link>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/523901#M839</link>
      <description>&lt;P&gt;the "customername" parameter is optional.&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;login&lt;/SPAN&gt;():&lt;BR /&gt;    header = {&lt;SPAN&gt;'Content-Type'&lt;/SPAN&gt;:&lt;SPAN&gt;'application/json'&lt;/SPAN&gt;}&lt;BR /&gt;    payload = {&lt;SPAN&gt;'username'&lt;/SPAN&gt;:&lt;SPAN&gt;'Access ID'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'password'&lt;/SPAN&gt;:&lt;SPAN&gt;'Secret Key'&lt;/SPAN&gt;}&lt;BR /&gt;&lt;BR /&gt;    response = requests.request(&lt;SPAN&gt;'POST'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'{}/login'&lt;/SPAN&gt;.format(API)&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;json&lt;/SPAN&gt;=payload&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;headers&lt;/SPAN&gt;=header)&lt;BR /&gt;&lt;BR /&gt;    json_response = response.json()&lt;BR /&gt;&lt;BR /&gt;    &lt;SPAN&gt;return &lt;/SPAN&gt;json_response[&lt;SPAN&gt;'token'&lt;/SPAN&gt;]&lt;BR /&gt;&lt;BR /&gt;JWT_TOKEN = login()&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 13 Dec 2022 07:50:34 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/prisma-cloud-discussions/mandatory-request-headers-for-redlock-api-x-redlock-auth/m-p/523901#M839</guid>
      <dc:creator>SSaripalli</dc:creator>
      <dc:date>2022-12-13T07:50:34Z</dc:date>
    </item>
  </channel>
</rss>

