aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/get-access-token.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-09 16:47:06 +0100
committerChocobozzz <me@florianbigard.com>2018-02-09 16:47:06 +0100
commita7fea183f0f69104b209e7bfdd6435be28165f22 (patch)
treea0bfb7daf8e9778c664b8d7224b2e1c382e3834e /server/tools/get-access-token.ts
parent1185c246c591a0783dc0ab268bbd67eba1d46bb9 (diff)
downloadPeerTube-a7fea183f0f69104b209e7bfdd6435be28165f22.tar.gz
PeerTube-a7fea183f0f69104b209e7bfdd6435be28165f22.tar.zst
PeerTube-a7fea183f0f69104b209e7bfdd6435be28165f22.zip
Begin import script with youtube-dl
Diffstat (limited to 'server/tools/get-access-token.ts')
-rw-r--r--server/tools/get-access-token.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/server/tools/get-access-token.ts b/server/tools/get-access-token.ts
new file mode 100644
index 000000000..66fa70814
--- /dev/null
+++ b/server/tools/get-access-token.ts
@@ -0,0 +1,48 @@
1import * as program from 'commander'
2
3import {
4 getClient,
5 serverLogin
6} from '../tests/utils/index'
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
34getClient(program.url)
35 .then(res => {
36 server.client.id = res.body.client_id
37 server.client.secret = res.body.client_secret
38
39 return serverLogin(server)
40 })
41 .then(accessToken => {
42 console.log(accessToken)
43 process.exit(0)
44 })
45 .catch(err => {
46 console.error(err)
47 process.exit(-1)
48 })