-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_r.py
29 lines (22 loc) · 925 Bytes
/
test_r.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
import r
import os
# Set these:
org_url = os.environ['OKTA_CLIENT_ORGURL']
token = os.environ['OKTA_CLIENT_TOKEN']
group_id = '...'
r.headers['authorization'] = 'SSWS ' + token
res = r.get(f'{org_url}/api/v1/users/me')
me = res.json
user_id = me['id']
print(me['profile']['login'], me['profile']['title'], res.headers['x-rate-limit-remaining'])
# Pagination.
url = r.url(f'{org_url}/api/v1/users', filter='profile.lastName eq "Doe"', limit=2)
for user in r.get_objects(url):
print(user['profile']['login'])
# res = r.post(f'{org_url}/api/v1/users/{user_id}', {'profile': {'title': 'admin'}})
# me = res.json
# print(me['profile']['title'], res.headers['x-rate-limit-remaining'])
# res = r.put(f'{org_url}/api/v1/groups/{group_id}/users/{user_id}')
# print(res.headers['x-rate-limit-remaining'])
# res = r.delete(f'{org_url}/api/v1/groups/{group_id}/users/{user_id}')
# print(res.headers['x-rate-limit-remaining'])