I'm trying to create an http put request to use Azure REST API to create a resource group using parameters that are created with an HTML form. When trying to send the request I receive an error that my header is invalid for the authorization header.
Here is the error I receive
Exception has occurred: InvalidHeader
Value for header {Authorization: {'access_token': 'MYACCESSTOKEN', 'token_type': 'Bearer', 'expires_in': 583}} must be of type str or bytes, not <class 'dict'>
Here is my code
@app.route('/storageaccountcreate', methods = ['POST', 'PUT'])
def storageaccountcreate():
name = request.form['storageaccountname']
resourcegroup = request.form['resourcegroup']
subscriptionId = request.form['subscriptionId']
location = request.form['location']
sku = request.form['sku']
headers = {"Authorization": _get_token_from_cache(app_config.SCOPE)}
url = f'https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourcegroup}/providers/Microsoft.Storage/storageAccounts/{name}?api-version=2019-06-01'
r = requests.put(url, headers=headers)
print(r.text)
return(r.text)