This is how I'm logging in to the API and setting up headers for subsequent requests using Python. # Configuration REDLOCK_API_URL = 'https://api.redlock.io' REDLOCK_CUSTOMER_NAME = 'example.com' REDLOCK_USER_NAME = 'joe.smith@example.com' redlock_api_headers = { 'Content-Type' : 'application/json' , 'x-redlock-auth' : '' , 'cache-control' : 'no-cache' } redlock_password = getpass.getpass( "Enter RedLock password for {} : " .format( REDLOCK_USER_NAME )) # login to RedLock API redlock_api_payload_login = { 'username' : REDLOCK_USER_NAME , 'customerName' : REDLOCK_CUSTOMER_NAME , 'password' : redlock_password } request_url = ' {} /login' .format( REDLOCK_API_URL ) response = requests.request( "POST" , request_url, data = json.dumps(redlock_api_payload_login), headers = redlock_api_headers) redlock_api_headers[ 'x-redlock-auth' ] = json.loads(response.text)[ 'token' ]
... View more