Skip to content

Instantly share code, notes, and snippets.

View lacerdaeduardo's full-sized avatar

Eduardo Lacerda lacerdaeduardo

View GitHub Profile
@lacerdaeduardo
lacerdaeduardo / requests_debug_level.py
Created August 27, 2020 13:56
Enable Python requests debug log level
import logging
from http.client import HTTPConnection # py3
log = logging.getLogger('urllib3')
log.setLevel(logging.DEBUG)
# logging from urllib3 to console
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
log.addHandler(ch)
PROFILE=profile
MFA_SERIAL=xxx
USER=xxx
RESULT=$(aws sts get-session-token --serial-number arn:aws:iam::${MFA_SERIAL}:mfa/${USER} --token-code $1 --profile ${PROFILE})
ACCESS_KEY_ID="$(echo $RESULT | jq '.Credentials.AccessKeyId' -r)"
SECRET_KEY=$(echo $RESULT | jq '.Credentials.SecretAccessKey' -r)
TOKEN=$(echo $RESULT | jq '.Credentials.SessionToken' -r)