]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/real-world/tools/get-access-token.js
Server: refractoring upload/update video test utils
[github/Chocobozzz/PeerTube.git] / server / tests / real-world / tools / get-access-token.js
CommitLineData
677618d4
C
1'use strict'
2
3const program = require('commander')
4
3fad43ac
C
5const utilsClient = require('../../utils/clients')
6const utilsLogin = require('../../utils/login')
677618d4
C
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
3fad43ac 34utilsClient.getClient(program.url, function (err, res) {
677618d4
C
35 if (err) throw err
36
37 server.client.id = res.body.client_id
38 server.client.secret = res.body.client_secret
39
3fad43ac 40 utilsLogin.loginAndGetAccessToken(server, function (err, accessToken) {
677618d4
C
41 if (err) throw err
42
43 console.log(accessToken)
44 })
45})