Skip to content

Commit

Permalink
fix client grants provider example (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurugana authored Nov 24, 2020
1 parent 0b4e2ce commit 6d75c5b
Showing 1 changed file with 3 additions and 8 deletions.
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

0 comments on commit 6d75c5b

Please sign in to comment.