<?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: How to retrieve from CCP API using Python and certificate auth in Secrets Management</title>
    <link>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308823#M226</link>
    <description>&lt;P&gt;The error states the APPID is not created. Did you create this Application ID under applications?&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jan 2024 20:18:57 GMT</pubDate>
    <dc:creator>V.Vasanth982517</dc:creator>
    <dc:date>2024-01-05T20:18:57Z</dc:date>
    <item>
      <title>How to retrieve from CCP API using Python and certificate auth</title>
      <link>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308822#M225</link>
      <description>&lt;P&gt;I see this error when trying to retrieve an account via the CCP REST API using Python. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{"ErrorCode":"APPAP008E","ErrorMsg":"Problem occurred while trying to use user in the Vault (Error: ITATS982E User APPID is not defined.&amp;nbsp;Diagnostic Info: 6)"}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The retrieval fails the same way using each of requests, http client and pyaim modules&lt;/P&gt;&lt;P&gt;The retrieval of the same account succeeds using PowerShell. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to get a sample working using the requests module. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---------- sample script ---------&lt;/P&gt;&lt;P&gt;import requests&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Safe = "THESAFE"&lt;/P&gt;&lt;P&gt;AppID = "APPID"&lt;/P&gt;&lt;P&gt;AccountUserName = "USERNAME"&lt;/P&gt;&lt;P&gt;baseURL = "https://ccp.company.com"&lt;/P&gt;&lt;P&gt;url = f'{baseURL}/AIMWebService/api/Accounts'&lt;/P&gt;&lt;P&gt;CertPath = 'C:\\Local\\ccp_retrieve\\client_cert_with_chain.pem'&lt;/P&gt;&lt;P&gt;KeyPath = 'C:\\Local\\ccp_retrieve\\client_cert.key'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;querystring = {&lt;/P&gt;&lt;P&gt;                "AppID": AppID,&lt;/P&gt;&lt;P&gt;                "Safe": Safe,&lt;/P&gt;&lt;P&gt;                "UserName": AccountUserName&lt;/P&gt;&lt;P&gt;               }&lt;/P&gt;&lt;P&gt;headers = {'content-type': 'application/json'}&lt;/P&gt;&lt;P&gt;response = requests.request("GET", url, headers=headers, params=querystring, cert=(CertPath,KeyPath), verify=False)&lt;/P&gt;&lt;P&gt;print(response.text)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 19:47:22 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308822#M225</guid>
      <dc:creator>YetAnotherSmith</dc:creator>
      <dc:date>2024-01-05T19:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve from CCP API using Python and certificate auth</title>
      <link>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308823#M226</link>
      <description>&lt;P&gt;The error states the APPID is not created. Did you create this Application ID under applications?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 20:18:57 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308823#M226</guid>
      <dc:creator>V.Vasanth982517</dc:creator>
      <dc:date>2024-01-05T20:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve from CCP API using Python and certificate auth</title>
      <link>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308824#M227</link>
      <description>&lt;P&gt;APPAP008E information from the docs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;https://docs.cyberark.com/credential-providers/latest/en/Content/MESSAGES/Application%20Provider%20Messages%20-%20General.htm#&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;https://docs.cyberark.com/credential-providers/Latest/en/Content/CP%20for%20zOS/Activity-on-the-Central-Credential-Provider.htm&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;https://community.cyberark.com/s/article/CP-APPAP008E-Problem-occurred-while-trying-to-use-user-in-the-Vault-Error-The-user-doesn-t-exist-Diagnostic-Info-9&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 21:40:22 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308824#M227</guid>
      <dc:creator>P.Maan845601</dc:creator>
      <dc:date>2024-01-05T21:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve from CCP API using Python and certificate auth</title>
      <link>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308825#M228</link>
      <description>&lt;P&gt;Yes, the retrieval of the same account (via the same APPID) succeeds using PowerShell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed while doublechecking that the PowerShell sample is using the PVWA endpoint, while the Python sample uses the CCP endpoint. this looks like a piece of the puzzle. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Url in the Python sample:&lt;/P&gt;&lt;P&gt;https://ccp.company.com/AIMWebService/api/Accounts?AppID=APPID&amp;amp;Safe=THESAFE&amp;amp;UserName=USERNAME&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Uri in the PowerShell sample:&lt;/P&gt;&lt;P&gt;https://pvwa.company.com/AIMWebService/api/Accounts?AppID=APPID&amp;amp;Safe=THESAFE&amp;amp;UserName=USERNAME&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jan 2024 18:02:36 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308825#M228</guid>
      <dc:creator>YetAnotherSmith</dc:creator>
      <dc:date>2024-01-06T18:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve from CCP API using Python and certificate auth</title>
      <link>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308826#M229</link>
      <description>&lt;P&gt;Got it. Of the laundry list in the first two links, #4 was the issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"The application user does not exist. The application user cannot be defined or is defined in a location that is not visible to the&amp;nbsp;Credential Provider&amp;nbsp;user"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The user did exist, but not in the deployment I needed. The endpoint I was using (CCP endpoint) was pointing at a different deployment, which didn't contain the AppId. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The PowerShell sample (using the PVWA endpoint in a different deployment) was able to see the AppId and retrieve the secret.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jan 2024 19:45:25 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308826#M229</guid>
      <dc:creator>YetAnotherSmith</dc:creator>
      <dc:date>2024-01-06T19:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve from CCP API using Python and certificate auth</title>
      <link>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308827#M230</link>
      <description>&lt;P&gt;To troubleshoot the error and get a working sample using the `requests` module, follow these steps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Check the AppID and UserName**: Ensure that the `AppID` and `AccountUserName` are correctly defined and have the necessary permissions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Verify the Certificate Paths**: Confirm that the paths to the certificate and key files are correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Adjust the Request**: Use `requests.get` instead of `requests.request("GET", ...)`, and ensure that the URL and parameters are correctly formatted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a sample script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;```&lt;A alt="https://iqratechnology.com/hire-python-developer/" href="https://iqratechnology.com/hire-python-developer/" target="_blank"&gt;python&lt;/A&gt;&lt;/P&gt;&lt;P&gt;import requests&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Safe = "THESAFE"&lt;/P&gt;&lt;P&gt;AppID = "APPID"&lt;/P&gt;&lt;P&gt;AccountUserName = "USERNAME"&lt;/P&gt;&lt;P&gt;baseURL = "https://ccp.company.com"&lt;/P&gt;&lt;P&gt;url = f'{baseURL}/AIMWebService/api/Accounts'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CertPath = 'C:\\Local\\ccp_retrieve\\client_cert_with_chain.pem'&lt;/P&gt;&lt;P&gt;KeyPath = 'C:\\Local\\ccp_retrieve\\client_cert.key'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;querystring = {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"AppID": AppID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"Safe": Safe,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;"UserName": AccountUserName&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;headers = {'content-type': 'application/json'}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;response = requests.get(url, headers=headers, params=querystring, cert=(CertPath, KeyPath), verify=False)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;response.raise_for_status()&amp;nbsp;# Raise an HTTPError for bad responses&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print(response.text)&lt;/P&gt;&lt;P&gt;except requests.exceptions.RequestException as e:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print(f"An error occurred: {e}")&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additional Tips:&lt;/P&gt;&lt;P&gt;Check Permissions: Ensure the user associated with the certificate has the correct permissions.&lt;/P&gt;&lt;P&gt;Debugging: Add `print(response.status_code, response.text)` to see more details about the response.&lt;/P&gt;&lt;P&gt;Certificate Validation: If you need to verify the server's SSL certificate, set `verify=True` or provide a path to the CA bundle file.&lt;/P&gt;&lt;P&gt;Logs: Check CCP logs for more details on the error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should help in diagnosing and fixing the issue with your API request.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 18:19:10 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/secrets-management/how-to-retrieve-from-ccp-api-using-python-and-certificate-auth/m-p/1308827#M230</guid>
      <dc:creator>CyberArkAlumni</dc:creator>
      <dc:date>2024-07-10T18:19:10Z</dc:date>
    </item>
  </channel>
</rss>

