]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tools/peertube-get-access-token.ts
Fix upload avatar button
[github/Chocobozzz/PeerTube.git] / server / tools / peertube-get-access-token.ts
index 9488eba0eb516ab48eac3a87ce786399ab6fcf14..d59a3632e4e4bec56fccebbaf05d501db500b308 100644 (file)
@@ -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 './cli'
 
 program
   .option('-u, --url <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 => {