Skip to content

Instantly share code, notes, and snippets.

@infamousjoeg
Created August 11, 2025 16:32
Show Gist options
  • Save infamousjoeg/90f4cd959d35798028c9fb447375bdf4 to your computer and use it in GitHub Desktop.
Save infamousjoeg/90f4cd959d35798028c9fb447375bdf4 to your computer and use it in GitHub Desktop.
How to authenticate as an Identity Service User using Ark SDK for Python
import getpass
from ark_sdk_python import ArkClient
from ark_sdk_python.auth import ArkISPAuth
def interactive_platform_auth():
"""Interactive platform token authentication setup"""
# Gather credentials interactively
tenant_url = input("Enter your CyberArk tenant URL: ")
client_id = input("Enter your Service User client ID: ")
client_secret = getpass.getpass("Enter your Service User client secret: ")
# Set up ISP auth with client credentials
auth = ArkISPAuth(
tenant_url=tenant_url,
client_id=client_id,
client_secret=client_secret,
grant_type='client_credentials'
)
# Initialize client
client = ArkClient(auth=auth)
try:
# Authenticate to get platform token
client.authenticate()
print("✓ Platform token authentication successful!")
# Return authenticated client for further use
return client
except Exception as e:
print(f"✗ Authentication failed: {e}")
return None
# Usage
if __name__ == "__main__":
client = interactive_platform_auth()
if client:
# Example operations with authenticated client
try:
# List available safes
safes = client.safes.list()
print(f"Available safes: {[safe.safe_name for safe in safes]}")
except Exception as e:
print(f"API operation failed: {e}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment