Skip to content

Instantly share code, notes, and snippets.

@vl4dt
Created November 26, 2015 19:03
Show Gist options
  • Save vl4dt/10fcbbb14779595f5c9c to your computer and use it in GitHub Desktop.
Save vl4dt/10fcbbb14779595f5c9c to your computer and use it in GitHub Desktop.
Azure AD Graph API call
Azure AD Graph API - INIT
request_id = str(uuid.uuid4())
# url = 'https://graph.windows.net/{0}/{resource-path}?[query-parameters]'
url = 'https://graph.microsoft.com/me?v1.0'
tenant = 'lnodev.onmicrosoft.com'
headers = {
'User-Agent': 'python_tutorial/1.0',
'Accept': 'application/json',
'Authorization': 'Bearer %s' % token,
'Content-Type': 'application/json',
'client-request-id': request_id,
'return-client-request-id': 'true'
}
response = requests.post(url, headers=headers)
json_response = {"result": "An error occurred"}
json_response = response.json()
logging.info('GRAPH RESPONSE: %s' % response)
logging.info('GRAPH RESPONSE json: %s' % json_response)
Azure AD Graph API - END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment