Skip to main content

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}")

Python Version Support

  • Python 3.10+

Dependencies

  • PyJWT >= 2.8.0
  • cryptography >= 42.0.0
  • httpx >= 0.25.0

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pm_party_client-0.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pm_party_client-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pm_party_client-0.1.0.tar.gz.

File metadata

  • Download URL: pm_party_client-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pm_party_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 325794e3f1d6b021c784495341117c108e55450766a9a5935dc748d4bea5b177
MD5 aecafb3fff6281159a4d71fd684b2372
BLAKE2b-256 a3a930e57339f271daef5d9e7b63456ea4544b47a14b677710044e600d43a048

See more details on using hashes here.

File details

Details for the file pm_party_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pm_party_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8dcc9714bd72f3ddb7415f17946392b1f6ba5f5fcde9f3d47afdd746cacc736
MD5 1a5936e6fbd2776b47f62422071eee69
BLAKE2b-256 ad15b669fe275e7bbc3c583e48fccf922207e80afea0dec11e52a360295369ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page