]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/real-world/tools/get-access-token.js
483cefa952c3319699dd0b07342f69e473843304
[github/Chocobozzz/PeerTube.git] / server / tests / real-world / tools / get-access-token.js
1 'use strict'
2
3 const program = require('commander')
4
5 const utilsClient = require('../../utils/clients')
6 const utilsLogin = require('../../utils/login')
7
8 program
9 .option('-u, --url <url>', 'Server url')
10 .option('-n, --username <username>', 'Username')
11 .option('-p, --password <token>', 'Password')
12 .parse(process.argv)
13
14 if (
15 !program.url ||
16 !program.username ||
17 !program.password
18 ) {
19 throw new Error('All arguments are required.')
20 }
21
22 const 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
34 utilsClient.getClient(program.url, function (err, res) {
35 if (err) throw err
36
37 server.client.id = res.body.client_id
38 server.client.secret = res.body.client_secret
39
40 utilsLogin.loginAndGetAccessToken(server, function (err, accessToken) {
41 if (err) throw err
42
43 console.log(accessToken)
44 })
45 })