<?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 credentials from CCP API using Python and OS username in PAM Self-Hosted Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306658#M9013</link>
    <description>&lt;P&gt;Working Python script without explicitly specifying the username / password for OS Authentication&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Ensure that CCP server and the server from where you execute this script are in same domain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import win32com.client, json&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Host = "https://pvwauat.com/AIMWebService/api/Accounts"&lt;/P&gt;&lt;P&gt;AppID = "DiscoveryScanApplication"&lt;/P&gt;&lt;P&gt;Safe = "DiscoveryScanAppWindows"&lt;/P&gt;&lt;P&gt;Folder = "Root"&lt;/P&gt;&lt;P&gt;Object = "Operating System-AD-ERDRSSD40D.COMPANY-HPDRDTAN"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;url = Host+'?AppID='+AppID+'&amp;amp;Folder='+Folder+'&amp;amp;safe='+Safe+'&amp;amp;object='+Object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;httpsRequest = win32com.client.Dispatch('WinHTTP.WinHTTPRequest.5.1')&lt;/P&gt;&lt;P&gt;httpsRequest.SetAutoLogonPolicy(0)&lt;/P&gt;&lt;P&gt;httpsRequest.Open('GET', url, False)&lt;/P&gt;&lt;P&gt;httpsRequest.Send()&lt;/P&gt;&lt;P&gt;result = httpsRequest.responseText&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Check the response&lt;/P&gt;&lt;P&gt;if httpsRequest.Status == 200:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print("Successfully authenticated.")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;jsonResponse = json.loads(result)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;username = jsonResponse.get('UserName')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;password = jsonResponse.get('Content')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print("UserName : " + username + " Password : " + password)&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print(f"Failed to authenticate. Status code: {httpsRequest.Status}")&lt;/P&gt;</description>
    <pubDate>Thu, 13 Feb 2025 07:01:23 GMT</pubDate>
    <dc:creator>T.Ramasamy969505</dc:creator>
    <dc:date>2025-02-13T07:01:23Z</dc:date>
    <item>
      <title>how to retrieve credentials from CCP API using Python and OS username</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306653#M9008</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm a newbie In Cyberark CCP and I wondering how can I get the credential from CCP with OS username authentication.&lt;/P&gt;&lt;P&gt;I can get the credential by Powershell script like this &lt;/P&gt;&lt;CODE&gt;$appid = 'My_APP'
$safe = 'My_Safe'
$credtofetch = 'My_Account'
#execute REST API call
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
invoke-restmethod -Credential (get-credential) -uri https://abc.mydomain.com/aimwebservice/api/accounts -method GET -Body @{AppID =
$appid; Safe = $safe; UserName = $credtofetch; Reason = 'Powershell'}&lt;/CODE&gt;&lt;P&gt;But I cannot find the way to get the credential when using python code.&lt;/P&gt;&lt;P&gt;my code always return 403 with error "&lt;B&gt;APPAP133E Failed to verify application authentication data: OSUser \\" \\" is unauthorized&lt;/B&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Python code&lt;/P&gt;&lt;CODE&gt;import requests
from requests_ntlm import HttpNtlmAuth
import getpass
import ssl
# Replace these values with your API endpoint and Windows domain
certificate_path = 'C:MyClientCert\certificate.pem'
ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_context.load_cert_chain(certfile=certificate_path)
api_url = 'https://abc.mydomain.com/AIMWebService/api/Accounts?AppID=my_app&amp;amp;Safe=My_safe&amp;amp;Object=My_Account'
domain = 'mydomain.com'
# Get the current Windows username
windows_username = getpass.getuser()
&amp;nbsp;
# Prompt for the Windows password
windows_password = getpass.getpass(f"Enter the password for {windows_username}@{domain}: ")
&amp;nbsp;
# Make a request to the API using NTLM authentication
response = requests.get(api_url, auth=HttpNtlmAuth(f'{domain}\\{windows_username}', windows_password),cert=certificate_path, verify=False)
&amp;nbsp;
# Check the response
if response.status_code == 200:
    print("Successfully authenticated.")
    print("Response:")
    print(response.text)
else:
    print(f"Failed to authenticate. Status code: {response.status_code}")&lt;/CODE&gt;&lt;P&gt;does anyone have succeeded with this aspect can give me your Python code? &lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 06:34:57 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306653#M9008</guid>
      <dc:creator>CyberArkAlumni</dc:creator>
      <dc:date>2024-01-26T06:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to retrieve credentials from CCP API using Python and OS username</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306654#M9009</link>
      <description>&lt;P&gt;@Hiep Nguyen?&amp;nbsp; This article should help you resolve your issue &lt;/P&gt;&lt;P&gt;https://community.cyberark.com/s/article/CCP-AIMWebService-Windows-Authentication-not-working&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 13:57:08 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306654#M9009</guid>
      <dc:creator>V.Vasanth982517</dc:creator>
      <dc:date>2024-01-26T13:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to retrieve credentials from CCP API using Python and OS username</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306655#M9010</link>
      <description>&lt;P&gt;Hi @Hiep Nguyen​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;The error&lt;/B&gt; you're encountering indicates an authorisation issue, and it seems to be related to the application authentication. Please verify that you have the necessary permissions to access the specified account in the Safe, and that your application has the required privileges.  &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please refer to the link shared by @Vinay Vasanth​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;The Python scrip&lt;/B&gt;t, it looks good to me. There are couple of observations.  &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.The requests_ntlm library already handles NTLM authentication, so you don't need to manually construct the authentication string&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change the line, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;response = requests.get(api_url, auth=HttpNtlmAuth(f'{domain}\\{windows_username}', windows_password), cert=certificate_path, verify=False)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;response = requests.get(api_url, auth=HttpNtlmAuth(f'{windows_username}@{domain}', windows_password), cert=(certificate_path, certificate_path), verify=False)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.It's not recommended to disable SSL verification (verify=False). Instead, provide the path to the CA certificate used by the server&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 04:07:42 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306655#M9010</guid>
      <dc:creator>M.Vora780263</dc:creator>
      <dc:date>2024-01-29T04:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to retrieve credentials from CCP API using Python and OS username</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306656#M9011</link>
      <description>&lt;P&gt;Hello @Vinay Vasanth​&amp;nbsp;. All configurations based on the document have been set already. but it is still the same. and the problem is Python code does not work, but Powershell still works correctly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 07:22:28 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306656#M9011</guid>
      <dc:creator>CyberArkAlumni</dc:creator>
      <dc:date>2024-01-29T07:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to retrieve credentials from CCP API using Python and OS username</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306657#M9012</link>
      <description>&lt;P&gt;Working Python script without explicitly specifying the username / password for OS Authentication&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Ensure that CCP server and the server from where you execute this script are in same domain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import win32com.client, json&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Host = "https://pvwauat.com/AIMWebService/api/Accounts"&lt;/P&gt;&lt;P&gt;AppID = "DiscoveryScanApplication"&lt;/P&gt;&lt;P&gt;Safe = "DiscoveryScanAppWindows"&lt;/P&gt;&lt;P&gt;Folder = "Root"&lt;/P&gt;&lt;P&gt;Object = "Operating System-AD-ERDRSSD40D.COMPANY-HPDRDTAN"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;url = Host+'?AppID='+AppID+'&amp;amp;Folder='+Folder+'&amp;amp;safe='+Safe+'&amp;amp;object='+Object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;httpsRequest = win32com.client.Dispatch('WinHTTP.WinHTTPRequest.5.1')&lt;/P&gt;&lt;P&gt;httpsRequest.SetAutoLogonPolicy(0)&lt;/P&gt;&lt;P&gt;httpsRequest.Open('GET', url, False)&lt;/P&gt;&lt;P&gt;httpsRequest.Send()&lt;/P&gt;&lt;P&gt;result = httpsRequest.responseText&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Check the response&lt;/P&gt;&lt;P&gt;if httpsRequest.Status == 200:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print("Successfully authenticated.")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;jsonResponse = json.loads(result)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;username = jsonResponse.get('UserName')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;password = jsonResponse.get('Content')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print("UserName : " + username + " Password : " + password)&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print(f"Failed to authenticate. Status code: {httpsRequest.Status}")&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 07:00:46 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306657#M9012</guid>
      <dc:creator>T.Ramasamy969505</dc:creator>
      <dc:date>2025-02-13T07:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to retrieve credentials from CCP API using Python and OS username</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306658#M9013</link>
      <description>&lt;P&gt;Working Python script without explicitly specifying the username / password for OS Authentication&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Ensure that CCP server and the server from where you execute this script are in same domain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import win32com.client, json&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Host = "https://pvwauat.com/AIMWebService/api/Accounts"&lt;/P&gt;&lt;P&gt;AppID = "DiscoveryScanApplication"&lt;/P&gt;&lt;P&gt;Safe = "DiscoveryScanAppWindows"&lt;/P&gt;&lt;P&gt;Folder = "Root"&lt;/P&gt;&lt;P&gt;Object = "Operating System-AD-ERDRSSD40D.COMPANY-HPDRDTAN"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;url = Host+'?AppID='+AppID+'&amp;amp;Folder='+Folder+'&amp;amp;safe='+Safe+'&amp;amp;object='+Object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;httpsRequest = win32com.client.Dispatch('WinHTTP.WinHTTPRequest.5.1')&lt;/P&gt;&lt;P&gt;httpsRequest.SetAutoLogonPolicy(0)&lt;/P&gt;&lt;P&gt;httpsRequest.Open('GET', url, False)&lt;/P&gt;&lt;P&gt;httpsRequest.Send()&lt;/P&gt;&lt;P&gt;result = httpsRequest.responseText&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Check the response&lt;/P&gt;&lt;P&gt;if httpsRequest.Status == 200:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print("Successfully authenticated.")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;jsonResponse = json.loads(result)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;username = jsonResponse.get('UserName')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;password = jsonResponse.get('Content')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print("UserName : " + username + " Password : " + password)&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;print(f"Failed to authenticate. Status code: {httpsRequest.Status}")&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 07:01:23 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/how-to-retrieve-credentials-from-ccp-api-using-python-and-os/m-p/1306658#M9013</guid>
      <dc:creator>T.Ramasamy969505</dc:creator>
      <dc:date>2025-02-13T07:01:23Z</dc:date>
    </item>
  </channel>
</rss>

