X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftools%2Fpeertube-get-access-token.ts;h=71a4826e8f90e5f2410aee535a1238e9c742bf86;hb=644391bee644c9078695ab042743d108870de7ef;hp=9488eba0eb516ab48eac3a87ce786399ab6fcf14;hpb=12152aa09ff47dc5c5a627c27030855e254e58ad;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tools/peertube-get-access-token.ts b/server/tools/peertube-get-access-token.ts index 9488eba0e..71a4826e8 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 { program } from 'commander' -import { getClient, Server, serverLogin } from '../../shared/extra-utils' +import { assignToken, buildServer } from './shared' 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 => {