Skip to content

Instantly share code, notes, and snippets.

@daemonfire300
Created February 27, 2025 15:17
Show Gist options
  • Save daemonfire300/e77cd01899367ef309f0a71db8cdfb08 to your computer and use it in GitHub Desktop.
Save daemonfire300/e77cd01899367ef309f0a71db8cdfb08 to your computer and use it in GitHub Desktop.
Minio STS Sample in Python without RoleArn
import requests
def make_post_request(base_url, action, duration_seconds, web_identity_token, version):
# Define the URL and query parameters
url = base_url
params = {
"Action": action,
"DurationSeconds": duration_seconds,
"WebIdentityToken": web_identity_token,
"Version": version
}
# Make the POST request with the query parameters
response = requests.post(url, params=params)
# Return the response
return response
# Example usage
base_url = "http://minio.cluster:9000"
action = "AssumeRoleWithWebIdentity"
duration_seconds = 3600
web_identity_token = "eyJ4NXQiOiJOVEF4Wm1NeE5ETXlaRGczTVRVMVpHTTBNekV6T0RKaFpXSTRORE5sWkRVMU9HRmtOakZpTVEiLCJraWQiOiJOVEF4Wm1NeE5ETXlaRGczTVRVMVpHTTBNekV6T0RKaFpXSTRORE5sWkRVMU9HRmtOakZpTVEiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJQb0VnWFA2dVZPNDVJc0VOUm5nRFhqNUF1NVlhIiwiYXpwIjoiUG9FZ1hQNnVWTzQ1SXNFTlJuZ0RYajVBdTVZYSIsImlzcyI6Imh0dHBzOlwvXC9sb2NhbGhvc3Q6OTQ0M1wvb2F1dGgyXC90b2tlbiIsImV4cCI6MTU0MTgwOTU4MiwiaWF0IjoxNTQxODA1OTgyLCJqdGkiOiI2Y2YyMGIwZS1lNGZmLTQzZmQtYTdiYS1kYTc3YTE3YzM2MzYifQ.Jm29jPliRvrK6Os34nSK3rhzIYLFjE__zdVGNng3uGKXGKzP3We_i6NPnhA0szJXMOKglXzUF1UgSz8MctbaxFS8XDusQPVe4LkB_45hwBm6TmBxzui911nt-1RbBLN_jZIlvl2lPrbTUH5hSn9kEkph6seWanTNQpz9tNEoVa6R_OX3kpJqxe8tLQUWw453A1JTwFNhdHa6-f1K8_Q_eEZ_4gOYINQ9t_fhTibdbkXZkJQFLop-Jwoybi9s4nwQU_dATocgcufq5eCeNItQeleT-23lGxIz0X7CiJrJynYLdd-ER0F77SumqEb5iCxhxuf4H7dovwd1kAmyKzLxpw"
version = "2011-06-15"
response = make_post_request(base_url, action, duration_seconds, web_identity_token, version)
print(response.status_code)
print(response.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment