This repository has been archived by the owner on Dec 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathoktaAppSAML.py
53 lines (44 loc) · 1.76 KB
/
oktaAppSAML.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
50
51
52
53
import requests
import json
# everything returns a 2xx on success and a 4xx on errors
oktaAPIToken = ""
oktaOrg = "org.oktapreview.com" # org.okta.com or org.oktapreview.com
headers = {'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'SSWS ' + oktaAPIToken}
data = {
"name": "template_app",
"label": "test-app",
"signOnMode": "SAML_2_0",
"settings": {
"app": {
"audienceRestriction": "http://localhost",
"forceAuthn": False,
"postBackURL": "http://localhost",
"authnContextClassRef": "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport",
"requestCompressed": "COMPRESSED",
"recipient": "http://localhost",
"signAssertion": "SIGNED",
"destination": "http://localhost",
"signResponse": "SIGNED",
"nameIDFormat": "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
"groupName": "",
"groupFilter": "",
"defaultRelayState": "",
"configuredIssuer": "",
"attributeStatements": ""
}
},
"visibility": {
"hide": {
"iOS": True,
"web": True
}
}
}
r = requests.post("https://" + oktaOrg + "/api/v1/apps", headers = headers, data = json.dumps(data)) # create an app
appid = r.json()["id"]
appid = ""
r = requests.get("https://" + oktaOrg + "/api/v1/apps/" + appid , headers = headers) # view an app
groupid = ""
r = requests.put("https://" + oktaOrg + "/api/v1/apps/" + appid + "/groups/" + groupid, headers = headers, data = {}) # assign a group to an app
r = requests.post("https://" + oktaOrg + "/api/v1/apps/" + appid + "/lifecycle/deactivate", headers = headers) # deactivate an app (before deletion)
r = requests.delete("https://" + oktaOrg + "/api/v1/apps/" + appid , headers = headers) # delete an app