Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Commit

Permalink
Create OktaDiffSlack.py
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbailey authored Jun 9, 2016
1 parent bad112d commit 338a4c1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions OktaDiffSlack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import json
import requests

slackAPIToken = ""
oktaAPIToken = ""
oktaGroup = ""
oktaOrg = ""

slackDeleted = []
slackBots = []
slackRestricted = []
slackUsers = []
r = requests.get("https://slack.com/api/users.list?token=" + slackAPIToken)
slackUsersJson = r.json()
for user in slackUsersJson['members']:
if (user['deleted'] == True): slackDeleted.append(user['profile']['real_name'])
elif (user['is_bot'] == True): slackBots.append(user['profile']['real_name'])
elif (user['is_restricted'] == True): slackRestricted.append(user['profile']['real_name'])
else: slackUsers.append(user['profile']['email'])

oktaUsers = []
r = requests.get("https://" + oktaOrg + ".okta.com/api/v1/groups/" + oktaGroup + "/users", headers={'Authorization': 'SSWS ' + oktaAPIToken})
oktaUsersJson = r.json()
for user in oktaUsersJson:
oktaUsers.append(user['profile']['login'])

inSlackNotInOkta = set(slackUsers) - set(oktaUsers)
inOktaNotInSlack = set(oktaUsers) - set(slackUsers)

print "These people are in Slack and not in Okta"
for user in inSlackNotInOkta:
print user

print "These people are in Okta and not in Slack"
for user in inOktaNotInSlack :
print user

0 comments on commit 338a4c1

Please sign in to comment.