]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tools/get-access-token.ts
Improve webtorrent import error message when the torrent has multiple
[github/Chocobozzz/PeerTube.git] / server / tools / get-access-token.ts
CommitLineData
8df87ce7 1import * as program from 'commander'
8df87ce7
C
2
3import {
4 getClient,
c1e791ba
RK
5 serverLogin,
6 Server,
7 Client,
8 User
a7fea183 9} from '../tests/utils/index'
8df87ce7
C
10
11program
12 .option('-u, --url <url>', 'Server url')
13 .option('-n, --username <username>', 'Username')
14 .option('-p, --password <token>', 'Password')
15 .parse(process.argv)
16
17if (
18 !program['url'] ||
19 !program['username'] ||
20 !program['password']
21) {
22 throw new Error('All arguments are required.')
23}
24
8df87ce7
C
25getClient(program.url)
26 .then(res => {
c1e791ba
RK
27 const server = {
28 url: program['url'],
29 user: {
30 username: program['username'],
31 password: program['password']
32 } as User,
33 client: {
34 id: res.body.client_id as string,
35 secret: res.body.client_secret as string
36 } as Client
37 } as Server
8df87ce7 38
eec63bbc 39 return serverLogin(server)
8df87ce7
C
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 })