]>
Commit | Line | Data |
---|---|---|
677618d4 C |
1 | 'use strict' |
2 | ||
3 | const program = require('commander') | |
4 | ||
5 | const utils = require('../../api/utils') | |
6 | ||
7 | program | |
8 | .option('-u, --url <url>', 'Server url') | |
9 | .option('-n, --username <username>', 'Username') | |
10 | .option('-p, --password <token>', 'Password') | |
11 | .parse(process.argv) | |
12 | ||
13 | if ( | |
14 | !program.url || | |
15 | !program.username || | |
16 | !program.password | |
17 | ) { | |
18 | throw new Error('All arguments are required.') | |
19 | } | |
20 | ||
21 | const server = { | |
22 | url: program.url, | |
23 | user: { | |
24 | username: program.username, | |
25 | password: program.password | |
26 | }, | |
27 | client: { | |
28 | id: null, | |
29 | secret: null | |
30 | } | |
31 | } | |
32 | ||
33 | utils.getClient(program.url, function (err, res) { | |
34 | if (err) throw err | |
35 | ||
36 | server.client.id = res.body.client_id | |
37 | server.client.secret = res.body.client_secret | |
38 | ||
39 | utils.loginAndGetAccessToken(server, function (err, accessToken) { | |
40 | if (err) throw err | |
41 | ||
42 | console.log(accessToken) | |
43 | }) | |
44 | }) |