Skip to content

Commit 544af43

Browse files
author
Markus Vilcinskas
committed
quickfix81
1 parent 8c45742 commit 544af43

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

articles/active-directory/active-directory-reporting-api-audit-samples.md

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -115,46 +115,6 @@ The script returns output from the audit report in JSON format. It also creates
115115

116116
echo $REPORT | ./jq-win64.exe -r '.value' | ./jq-win64.exe -r ".[]"
117117

118-
## Python script
119-
# Author: Michael McLaughlin ([email protected])
120-
# Date: January 20, 2016
121-
# This requires the Python Requests module: http://docs.python-requests.org
122-
123-
import requests
124-
import datetime
125-
import sys
126-
127-
client_id = 'your-application-client-id-here'
128-
client_secret = 'your-application-client-secret-here'
129-
login_url = 'https://login.microsoftonline.com/'
130-
tenant_domain = 'your-directory-name-here.onmicrosoft.com'
131-
132-
# Get an OAuth access token
133-
bodyvals = {'client_id': client_id,
134-
'client_secret': client_secret,
135-
'grant_type': 'client_credentials'}
136-
137-
request_url = login_url + tenant_domain + '/oauth2/token?api-version=1.0'
138-
token_response = requests.post(request_url, data=bodyvals)
139-
140-
access_token = token_response.json().get('access_token')
141-
token_type = token_response.json().get('token_type')
142-
143-
if access_token is None or token_type is None:
144-
print "ERROR: Couldn't get access token"
145-
sys.exit(1)
146-
147-
# Use the access token to make the API request
148-
yesterday = datetime.date.strftime(datetime.date.today() - datetime.timedelta(days=1), '%Y-%m-%d')
149-
150-
header_params = {'Authorization': token_type + ' ' + access_token}
151-
request_string = 'https://graph.windows.net/' + tenant_domain + '/activities/audit?api-version=beta&$filter=activityDate%20gt%20' + yesterday
152-
response = requests.get(request_string, headers = header_params)
153-
154-
if response.status_code is 200:
155-
print response.content
156-
else:
157-
print 'ERROR: API request failed'
158118

159119

160120

0 commit comments

Comments
 (0)