-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmassenroll.py
46 lines (33 loc) · 981 Bytes
/
massenroll.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
"""Simple but useful script to mass enroll users into a Webex space.
Set your accessToken, roomId, and provide emails to enroll as a list, or as a string one email per line
"""
accessToken = "your access token"
roomId = "your room ID"
emails = [
"user1@example.com",
"user2@example.com",
]
emails = """
user1@example.com
user2@example.com
"""
if type(emails) == str:
emails = list(filter(lambda s: s, map(lambda s: s.strip(), emails.splitlines())))
import requests
headers = {
'Authorization': "Bearer " + accessToken,
'Content-Type': "application/json; charset=utf-8"
}
i = 0
for email in emails:
i+=1
body = {
'roomId' : roomId,
'personEmail' : email,
}
resp = requests.post(
"https://webexapis.com/v1/memberships",
json = body,
headers = headers
)
print("{} Email: {} Status: {} {}".format(i, email, resp.status_code, resp.json()["message"] if "message" in resp.json() else ""))