Skip to main content

Official Python SDK for the G-PORTAL gpcore API

Project description

gpcore-py

The official Python SDK for the G-PORTAL gpcore API.

This is the Python counterpart to gpcore-go. It provides a pre-configured OIDC client and auto-generated protobuf/gRPC bindings for interacting with the gpcore API.

Installation

pip install gpcore-sdk

Usage

The following example authenticates using the client credentials flow and fetches the current user:

import grpc
from gpcore_sdk.client import APIClient
from gpcore_sdk.auth_strategies import (
    ClientCredentialsStrategy,
    CachedAuthStrategy,
)

from gpcore_sdk.protos.gpcore.api.auth.v1.rpc_pb2_grpc import AuthServiceStub
from gpcore_sdk.protos.gpcore.api.admin.v1.requests_pb2 import GetUserRequest


def main():
    auth = ClientCredentialsStrategy(
        client_id="YOUR_CLIENT_ID",
        client_secret="YOUR_CLIENT_SECRET",
    )

    client = APIClient(strategy=CachedAuthStrategy(auth, 30))
    stub = AuthServiceStub(client.channel)

    try:
        response = stub.GetUser(GetUserRequest())
        print(f"User: {response}")
    except grpc.RpcError as e:
        print(f"gRPC error: {e.code()} - {e.details()}")


if __name__ == "__main__":
    main()

Authentication Strategies

Strategy Description
ClientCredentialsStrategy OAuth2 client credentials flow. Recommended for service-to-service authentication.
UserPasswordStrategy Resource owner password flow. Requires a dedicated Keycloak OIDC client.
CachedAuthStrategy Wrapper that caches and auto-refreshes tokens from any underlying strategy.

Development

Regenerating protobuf bindings

If the API definitions have changed, regenerate the Python protobuf/gRPC code:

scripts/update_proto.sh

Local install

pip install -e .

Releasing

  1. Update the version in pyproject.toml.
  2. Commit, tag with the version number, and push the tag.
  3. The GitHub Actions workflow will build and publish to PyPI automatically.

License

This project is licensed under the Apache License 2.0.

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

gpcore_sdk-0.2.3.tar.gz (123.8 kB view details)

Uploaded Source

Built Distribution

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

gpcore_sdk-0.2.3-py3-none-any.whl (238.9 kB view details)

Uploaded Python 3

File details

Details for the file gpcore_sdk-0.2.3.tar.gz.

File metadata

  • Download URL: gpcore_sdk-0.2.3.tar.gz
  • Upload date:
  • Size: 123.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gpcore_sdk-0.2.3.tar.gz
Algorithm Hash digest
SHA256 cc63ef6e87ccbeb0bb3af784ec83f4fbb628c0806b3cef0532fe0ea3e7966523
MD5 e04554c4c4fe16f270257cdbabc7a25c
BLAKE2b-256 27fd7de62e7fdf69c8bf88d87be6dca4c8e73100b861bb6c20d2f88a323e8058

See more details on using hashes here.

Provenance

The following attestation bundles were made for gpcore_sdk-0.2.3.tar.gz:

Publisher: publish.yml on G-PORTAL/gpcore-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gpcore_sdk-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: gpcore_sdk-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 238.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gpcore_sdk-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4b2ffca1220d44c9a34c30ace3859454005a10ac9617479516b990ec33d2af25
MD5 14382d075e37b22aeff1fe24365e3d3a
BLAKE2b-256 0b11db210a349b019a39635174a48cb2814ca46758c5360ccb6fa5c1871d2e86

See more details on using hashes here.

Provenance

The following attestation bundles were made for gpcore_sdk-0.2.3-py3-none-any.whl:

Publisher: publish.yml on G-PORTAL/gpcore-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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