Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Original source code: https://docs.aws.amazon.com/en_us/IAM/latest/UserGuide/id_roles_providers_enable-console-custom-url.html
import urllib, json
import requests
access_key = ''
secret_key = ''
session_token = ''
json_string_with_temp_credentials = '{'
json_string_with_temp_credentials += '"sessionId":"' + access_key + '",'
json_string_with_temp_credentials += '"sessionKey":"' + secret_key + '",'
json_string_with_temp_credentials += '"sessionToken":"' + session_token + '"'
json_string_with_temp_credentials += '}'
request_parameters = "?Action=getSigninToken"
request_parameters += "&SessionDuration=43200"
request_parameters += "&Session=" + urllib.quote_plus(json_string_with_temp_credentials)
request_url = "https://signin.aws.amazon.com/federation" + request_parameters
r = requests.get(request_url)
signin_token = json.loads(r.text)
request_parameters = "?Action=login"
request_parameters += "&Issuer=Example.org"
request_parameters += "&Destination=" + urllib.quote_plus("https://console.aws.amazon.com/")
request_parameters += "&SigninToken=" + signin_token["SigninToken"]
request_url = "https://signin.aws.amazon.com/federation" + request_parameters
print request_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.