I am trying to make REST Call for azure using python, Have created Access token using ADAL in python. But getting Error called "provided Authorization header is in invalid format." Here is the code for that:
import adal
import requests
token_response = adal.acquire_token_with_username_password(
'https://login.windows.net/abcd.onmicrosoft.com',
'user-name',
'password'
)
access_token = token_response.get('accessToken')
url = 'https://management.azure.com/subscriptions/{subscription- id}/providers/Microsoft.Network/virtualnetworks?api-version=2015-06-15'
headers = {'Content-Type': 'application/json',
'Authorization': access_token}
response = requests.get(url=url,headers = headers)
print(response.status_code)
print(response.text)
Can anyone tell me how the access-token should look like? And is this the correct way to generate token for REST in python? I am reffering this link for above code: https://msdn.microsoft.com/en-us/library/azure/mt163557.aspx