-
Notifications
You must be signed in to change notification settings - Fork 0
/
okta_applications_per_user.py
executable file
·49 lines (41 loc) · 1.35 KB
/
okta_applications_per_user.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python
#
# The purpose of this script is to take the user's input of an email address
# and return the application's currently assigned to him.
#
# Updated for Python3+ 2020.09.2
#
import urllib2
import json
import csv
token = '{api_token}'
base_url = 'https://{subdomain}.okta.com/api/v1/'
headers = {'Authorization' : 'SSWS ' + token,
'Accept' : 'application/json',
'Content-Type' : 'application/json' }
email = raw_input("Enter the user's email address: ")
url = base_url + '/users?q=' + email
headers = {'Authorization' : 'SSWS ' + token,
'Accept' : 'application/json',
'Content-Type' : 'application/json' }
req = urllib2.Request(url, headers=headers)
response = urllib2.urlopen(req)
the_page = response.read()
json_obj = json.loads(the_page)
for json_row in json_obj:
display_name = json_row["profile"]["displayName"]
login = json_row["profile"]["login"]
title = json_row["profile"]["title"]
okta_id = json_row["id"]
url2 = base_url + '/users/' + okta_id + '/appLinks'
new_req = urllib2.Request(url2, headers=headers)
response = urllib2.urlopen(new_req)
the_page2 = response.read()
json_obj2 = json.loads(the_page2)
apps = ''
for json_row in json_obj2:
apps = apps + json_row["label"] + '; '
print ("Name: " + display_name)
print ("Login: " + login)
print ("Title: " + title)
print ("Apps: " + apps)