@@ -115,46 +115,6 @@ The script returns output from the audit report in JSON format. It also creates
115
115
116
116
echo $REPORT | ./jq-win64.exe -r '.value' | ./jq-win64.exe -r ".[]"
117
117
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'
158
118
159
119
160
120
0 commit comments