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
- Update the version in
pyproject.toml. - Commit, tag with the version number, and push the tag.
- The GitHub Actions workflow will build and publish to PyPI automatically.
License
This project is licensed under the Apache License 2.0.
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc63ef6e87ccbeb0bb3af784ec83f4fbb628c0806b3cef0532fe0ea3e7966523
|
|
| MD5 |
e04554c4c4fe16f270257cdbabc7a25c
|
|
| BLAKE2b-256 |
27fd7de62e7fdf69c8bf88d87be6dca4c8e73100b861bb6c20d2f88a323e8058
|
Provenance
The following attestation bundles were made for gpcore_sdk-0.2.3.tar.gz:
Publisher:
publish.yml on G-PORTAL/gpcore-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gpcore_sdk-0.2.3.tar.gz -
Subject digest:
cc63ef6e87ccbeb0bb3af784ec83f4fbb628c0806b3cef0532fe0ea3e7966523 - Sigstore transparency entry: 1470951577
- Sigstore integration time:
-
Permalink:
G-PORTAL/gpcore-py@a0a4e73feb1d61b05516638c5864c21e55e84cf5 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/G-PORTAL
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a0a4e73feb1d61b05516638c5864c21e55e84cf5 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b2ffca1220d44c9a34c30ace3859454005a10ac9617479516b990ec33d2af25
|
|
| MD5 |
14382d075e37b22aeff1fe24365e3d3a
|
|
| BLAKE2b-256 |
0b11db210a349b019a39635174a48cb2814ca46758c5360ccb6fa5c1871d2e86
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gpcore_sdk-0.2.3-py3-none-any.whl -
Subject digest:
4b2ffca1220d44c9a34c30ace3859454005a10ac9617479516b990ec33d2af25 - Sigstore transparency entry: 1470951756
- Sigstore integration time:
-
Permalink:
G-PORTAL/gpcore-py@a0a4e73feb1d61b05516638c5864c21e55e84cf5 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/G-PORTAL
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a0a4e73feb1d61b05516638c5864c21e55e84cf5 -
Trigger Event:
push
-
Statement type: