-
Notifications
You must be signed in to change notification settings - Fork 0
/
oc-getusers
executable file
·50 lines (36 loc) · 1.09 KB
/
oc-getusers
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
#!/bin/bash
dirName=`dirname $0`
progName=`basename $0`
# Usage
# =====
function usage() {
echo "NOM"
echo " $progName"
echo "SYNOPSIS"
echo " $progName client_login client_password"
echo "DESCRIPTION"
echo " Requests an access token on the authentication SERVEUR using client credentials,"
echo " then gets the list of all the users subs and names."
echo " role example : 'manager-dev:dictionary-user'"
}
# Command line
# ============
if [[ "$1" == "--help" || "$1" == "-h" || $# -ne 2 ]]; then
usage
exit 1
fi
# Execution
# =========
token=`${dirName}/oc-token $1 $2`
if [ "$token" == "null" ]; then
echo "ERREUR invalid token. Please check client credentials."
exit 1
fi
typeset -i offset
offset=0
count=50
# this is quick and dirty isn't it?
for i in `seq 4`; do
curl -s --header "Authorization: Bearer $token" "https://accounts.organicity.eu/permissions/users?offset=${offset}&count=${count}" | grep -v "\[\]" | sed "s/\"},{/\n/g" | sed "s/^\[{//" | sed "s/}\]/\n/" | cut -d '"' -f 4,8- | tr '"' ' ' | grep -Ev "^$"
offset=$offset+50
done