]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tools/peertube-get-access-token.ts
Add version to generate types packages
[github/Chocobozzz/PeerTube.git] / server / tools / peertube-get-access-token.ts
index b2c278c4876eb4dabd90ac03a7d8cd41de5448c4..a67de9180d3b9b1257adc2adef47dc0b728989f4 100644 (file)
@@ -1,8 +1,8 @@
 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 <url>', 'Server url')
@@ -24,24 +24,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 => {