Python SDK for Project Manager third-party authentication (Ed25519 + JWT + GraphQL)
Project description
pm-party-client
A lightweight Python SDK for third-party applications to authenticate and query the Project Manager GraphQL API using Ed25519 asymmetric key authentication.
Installation
pip install pm-party-client
Quick Start
from pm_party_client import PartyClient
client = PartyClient(
url="https://your-pm-instance.com/graphql",
app_id="your-app-id",
private_key_path="path/to/private_key.pem", # or use private_key="-----BEGIN PRIVATE KEY-----\n..."
)
# Execute a query
result = client.query("""
query {
getParties {
app_id
app_name
status
}
}
""")
print(result)
Configuration
Using a key file
client = PartyClient(
url="https://pm.example.com/graphql",
app_id="a1b2c3d4-...",
private_key_path="/secure/location/private_key.pem",
)
Using a key string
client = PartyClient(
url="https://pm.example.com/graphql",
app_id="a1b2c3d4-...",
private_key="-----BEGIN PRIVATE KEY-----\nMC4CAQ...\n-----END PRIVATE KEY-----",
)
Token lifetime
Tokens are short-lived by default (10 minutes). You can adjust:
client = PartyClient(
url="https://pm.example.com/graphql",
app_id="a1b2c3d4-...",
private_key_path="key.pem",
token_lifetime=300, # 5 minutes (max 3600)
)
Usage
Query
result = client.query("""
query GetParty($appId: String!) {
getParty(appId: $appId) {
app_name
status
public_key
}
}
""", variables={"appId": "some-app-id"})
Mutation
result = client.mutate("""
mutation CreateParty($input: CreatePartyInput!) {
createParty(input: $input) {
success
message
app_id
}
}
""", variables={"input": {"app_name": "New Service"}})
Raw execute
result = client.execute(
query="query { me { id email } }",
variables={},
operation_name="GetMe",
)
Custom headers
result = client.query(
"query { getParties { app_id } }",
headers={"X-Request-Id": "abc-123"},
)
Async Support
from pm_party_client import AsyncPartyClient
client = AsyncPartyClient(
url="https://pm.example.com/graphql",
app_id="a1b2c3d4-...",
private_key_path="key.pem",
)
result = await client.query("query { getParties { app_id } }")
await client.close()
# Or use as async context manager
async with AsyncPartyClient(url=..., app_id=..., private_key_path=...) as client:
result = await client.query("query { getParties { app_id } }")
Error Handling
from pm_party_client.exceptions import (
PMClientError,
PMAuthError,
PMGraphQLError,
PMConnectionError,
)
try:
result = client.query("query { me { id } }")
except PMAuthError as e:
print(f"Authentication failed: {e}")
except PMGraphQLError as e:
print(f"GraphQL errors: {e.errors}")
except PMConnectionError as e:
print(f"Connection failed: {e}")
except PMClientError as e:
print(f"Client error: {e}")
Health Check
Test your connection and credentials before making real API calls:
result = client.health()
# {'status': 200, 'message': 'connected', 'party': {'app_id': '...', 'app_name': '...'}}
Async:
result = await async_client.health()
Python Version Support
- Python 3.10+
Dependencies
PyJWT >= 2.8.0cryptography >= 42.0.0httpx >= 0.25.0
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pm_party_client-0.2.0.tar.gz.
File metadata
- Download URL: pm_party_client-0.2.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
303973608f11a2c225089bc236fb96496aa9c7f22e62d2c8a068894c78e0b38c
|
|
| MD5 |
687dc839b601718aa9c60b2aa8a6e054
|
|
| BLAKE2b-256 |
92059d0f06877a76932b323fa92f779c2e32c7077c59348630f6ec74b0b90e26
|
File details
Details for the file pm_party_client-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pm_party_client-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76a4444fe2c7e0e94a113eb78013c5d21148197b17b9572e5c67bda5ba729cf2
|
|
| MD5 |
13115b894903d9c3cba904569667a328
|
|
| BLAKE2b-256 |
f5d2320b83d8ca3e62e1503a951b797d89f9dd9f0a61de2929ac7eb797bd5d48
|