What is the best way to store a string variable as a string value in a dictionary?
Below I am trying to put a string variable named authToken and place it in the dictionary called header so I can call it using the requests module
if currentTime >= authExpTime: getAuthToken() else: header = {'Content-Type':'application/json','Authorization':'OAUTH2 access_token=authToken'} print header for i in metricsCollected: callURL = apiURL + i + "?samepletime=" print callURL apiResponse = requests.get(apiURL, headers=header) apiResponse.json()
OAUTH2 access_token=authToken) within another key/value pair ('Authorization':'OAUTH2 access_token=authToken'). A nested dictionary ({"OAUTH2 access_token" : "authToken"}) would be better but I didn't know whether his script would allow that or not.