aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/real-world/tools/get-access-token.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-07-20 19:16:00 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-07-20 19:16:00 +0200
commit677618d4a600a1678088d107850c8f1f8c95255f (patch)
treeb0ea636094a7a6c8188757bcd2a68ce1231e3d6f /server/tests/real-world/tools/get-access-token.js
parent2bd3f171270aff9717a55f2b89757fe966911af3 (diff)
downloadPeerTube-677618d4a600a1678088d107850c8f1f8c95255f.tar.gz
PeerTube-677618d4a600a1678088d107850c8f1f8c95255f.tar.zst
PeerTube-677618d4a600a1678088d107850c8f1f8c95255f.zip
Server: Add some cli tools to make it easy to upload a lot of videos
Diffstat (limited to 'server/tests/real-world/tools/get-access-token.js')
-rw-r--r--server/tests/real-world/tools/get-access-token.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/server/tests/real-world/tools/get-access-token.js b/server/tests/real-world/tools/get-access-token.js
new file mode 100644
index 000000000..4f98e9c9f
--- /dev/null
+++ b/server/tests/real-world/tools/get-access-token.js
@@ -0,0 +1,44 @@
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})