]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/real-world/tools/get-access-token.js
Server: Add some cli tools to make it easy to upload a lot of videos
[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
5const utils = require('../../api/utils')
6
7program
8 .option('-u, --url <url>', 'Server url')
9 .option('-n, --username <username>', 'Username')
10 .option('-p, --password <token>', 'Password')
11 .parse(process.argv)
12
13if (
14 !program.url ||
15 !program.username ||
16 !program.password
17) {
18 throw new Error('All arguments are required.')
19}
20
21const 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
33utils.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})