aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/get-access-token.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tools/get-access-token.ts')
-rw-r--r--server/tools/get-access-token.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/server/tools/get-access-token.ts b/server/tools/get-access-token.ts
new file mode 100644
index 000000000..66fa70814
--- /dev/null
+++ b/server/tools/get-access-token.ts
@@ -0,0 +1,48 @@
1import * as program from 'commander'
2
3import {
4 getClient,
5 serverLogin
6} from '../tests/utils/index'
7
8program
9 .option('-u, --url <url>', 'Server url')
10 .option('-n, --username <username>', 'Username')
11 .option('-p, --password <token>', 'Password')
12 .parse(process.argv)
13
14if (
15 !program['url'] ||
16 !program['username'] ||
17 !program['password']
18) {
19 throw new Error('All arguments are required.')
20}
21
22const server = {
23 url: program['url'],
24 user: {
25 username: program['username'],
26 password: program['password']
27 },
28 client: {
29 id: null,
30 secret: null
31 }
32}
33
34getClient(program.url)
35 .then(res => {
36 server.client.id = res.body.client_id
37 server.client.secret = res.body.client_secret
38
39 return serverLogin(server)
40 })
41 .then(accessToken => {
42 console.log(accessToken)
43 process.exit(0)
44 })
45 .catch(err => {
46 console.error(err)
47 process.exit(-1)
48 })