Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix client grants provider example #1027

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions examples/minio_with_client_grants_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
from minio.credentials import ClientGrantsProvider


def get_jwt(client_id, client_secret, idp_client_id, idp_endpoint):
def get_jwt(client_id, client_secret, idp_endpoint):
res = urllib3.PoolManager().request(
"POST",
idp_endpoint,
fields={
"username": client_id,
"password": client_secret,
"grant_type": "password",
"client_id": idp_client_id,
"grant_type": "client_credentials",
},
)

Expand All @@ -50,15 +49,11 @@ def get_jwt(client_id, client_secret, idp_client_id, idp_endpoint):
# Client secret to fetch JWT.
client_secret = "PASSWORD"

# Client-ID of MinIO service on IDP.
idp_client_id = "MINIO-CLIENT-ID"

# STS endpoint usually point to MinIO server.
sts_endpoint = "http://STS-HOST:STS-PORT/"

provider = ClientGrantsProvider(
lambda: get_jwt(client_id, client_secret, idp_client_id, idp_endpoint),
sts_endpoint,
lambda: get_jwt(client_id, client_secret, idp_endpoint), sts_endpoint,
)

client = Minio("MINIO-HOST:MINIO-PORT", credentials=provider)
Expand Down