X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftools%2Fpeertube-get-access-token.ts;h=d59a3632e4e4bec56fccebbaf05d501db500b308;hb=424aeb12bd16f5d6763dfa2860d113cc93876405;hp=b2c278c4876eb4dabd90ac03a7d8cd41de5448c4;hpb=ba5a8d89bbf049e4afc41543bcc072cccdb02669;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tools/peertube-get-access-token.ts b/server/tools/peertube-get-access-token.ts index b2c278c48..d59a3632e 100644 --- a/server/tools/peertube-get-access-token.ts +++ b/server/tools/peertube-get-access-token.ts @@ -1,8 +1,5 @@ -import { registerTSPaths } from '../helpers/register-ts-paths' -registerTSPaths() - -import * as program from 'commander' -import { getClient, Server, serverLogin } from '../../shared/extra-utils' +import { program } from 'commander' +import { assignToken, buildServer } from './cli' program .option('-u, --url ', 'Server url') @@ -24,24 +21,11 @@ if ( process.exit(-1) } -getClient(options.url) - .then(res => { - const server = { - url: options.url, - user: { - username: options.username, - password: options.password - }, - client: { - id: res.body.client_id, - secret: res.body.client_secret - } - } as Server +const server = buildServer(options.url) - return serverLogin(server) - }) - .then(accessToken => { - console.log(accessToken) +assignToken(server, options.username, options.password) + .then(() => { + console.log(server.accessToken) process.exit(0) }) .catch(err => {