{"id":9444,"library":"agilicus","title":"Agilicus Python SDK","description":"The Agilicus Python SDK provides a client for interacting with Agilicus APIs, facilitating secure access to protected resources and management operations. It is currently at version 1.415.0 and appears to follow a rapid release cadence based on frequent version bumps on PyPI, often without detailed public release notes.","status":"active","version":"1.415.0","language":"en","source_language":"en","source_url":"https://github.com/Agilicus","tags":["api-client","sdk","authentication","security","agilicus"],"install":[{"cmd":"pip install agilicus","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"Agilicus","correct":"import agilicus\nclient = agilicus.Agilicus()"}],"quickstart":{"code":"import os\nimport agilicus\n\n# Ensure AGILICUS_CLIENT_ID, AGILICUS_CLIENT_SECRET, AGILICUS_ISSUER are set as environment variables.\n# Example: os.environ['AGILICUS_CLIENT_ID'] = 'your_client_id_here'\n\n# The Agilicus client automatically picks up credentials from environment variables.\n# You can also pass them directly to the constructor.\nclient = agilicus.Agilicus()\n\ntry:\n    # Example: List users (requires appropriate permissions)\n    print(\"Attempting to list users...\")\n    users = client.list_users()\n    if users:\n        print(f\"Successfully listed {len(users)} users. First user ID: {users[0].id}\")\n    else:\n        print(\"No users found or client lacks permissions to list users.\")\n\n    # Example: Access a protected resource (replace with your actual resource path)\n    print(\"\\nAttempting to access a protected resource...\")\n    response = client.get_protected_resource(\"/api/v1/status\") # Illustrative endpoint\n    response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)\n    print(f\"Protected resource accessed successfully: {response.status_code}\")\n    print(response.json())\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure your Agilicus client is correctly configured with valid credentials and necessary permissions.\")","lang":"python","description":"Initializes the Agilicus client and demonstrates listing users and accessing a protected resource. Requires `AGILICUS_CLIENT_ID`, `AGILICUS_CLIENT_SECRET`, and `AGILICUS_ISSUER` environment variables to be set for authentication."},"warnings":[{"fix":"Ensure `AGILICUS_CLIENT_ID`, `AGILICUS_CLIENT_SECRET`, and `AGILICUS_ISSUER` environment variables are correctly set, or pass them directly to the `Agilicus()` constructor. Verify client permissions in your Agilicus console.","message":"Many SDK operations require correct authentication credentials (CLIENT_ID, CLIENT_SECRET, ISSUER) and appropriate permissions for the client account. Misconfiguration often leads to 401 Unauthorized or 403 Forbidden errors.","severity":"gotcha","affected_versions":"All"},{"fix":"Always call `response.raise_for_status()` after an API call (e.g., `client.get_protected_resource(...).raise_for_status()`) to automatically raise an `HTTPError` for bad responses, or explicitly check `response.ok` or `response.status_code`.","message":"API calls in the SDK often return `requests.Response` objects. Failing to check `response.raise_for_status()` or `response.ok` can lead to silently processing error responses (e.g., 404 Not Found) as if they were successful.","severity":"gotcha","affected_versions":"All"},{"fix":"Investigate if the `client.session` attribute provides access to the underlying `requests.Session` object for more granular control, or consider direct `requests` calls for highly specific HTTP interactions.","message":"The SDK primarily offers high-level wrappers. For advanced HTTP request features (e.g., custom headers, streaming responses, specific timeout handling) not directly exposed by SDK methods, you might need to access the underlying `client.session` object or fall back to raw `requests` calls.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Verify that your `AGILICUS_CLIENT_ID`, `AGILICUS_CLIENT_SECRET`, and `AGILICUS_ISSUER` environment variables or constructor arguments precisely match your Agilicus console settings and the correct issuer URL.","cause":"The Agilicus client failed to authenticate with the issuer. This is typically due to incorrect `AGILICUS_CLIENT_ID`, `AGILICUS_CLIENT_SECRET`, or `AGILICUS_ISSUER` configuration.","error":"requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: ..."},{"fix":"In your Agilicus console, check the client configuration associated with the `client_id` you are using. Ensure it has been granted the required scopes and roles for the API endpoints or resources you are trying to access.","cause":"The authenticated Agilicus client lacks the necessary permissions (scopes/roles) to perform the requested operation (e.g., `list_users` or accessing a specific protected resource).","error":"requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: ..."},{"fix":"Set the `AGILICUS_CLIENT_ID`, `AGILICUS_CLIENT_SECRET`, and `AGILICUS_ISSUER` environment variables before instantiating `agilicus.Agilicus()`, or pass these values directly as keyword arguments to the constructor (e.g., `agilicus.Agilicus(client_id=..., client_secret=..., issuer=...)`).","cause":"The `Agilicus` client was instantiated without providing credentials, and the necessary environment variables (`AGILICUS_CLIENT_ID`, `AGILICUS_CLIENT_SECRET`, `AGILICUS_ISSUER`) were not set.","error":"TypeError: Agilicus.__init__() missing 3 required positional arguments: 'client_id', 'client_secret', and 'issuer'"}]}