• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / boxcli / 5794698568

pending completion
5794698568

Pull #488

github

web-flow
Merge 96c25857d into 3bc6a83f7
Pull Request #488: docs: Update docs after release 3.9.2

1113 of 1441 branches covered (77.24%)

Branch coverage included in aggregate %.

4135 of 4633 relevant lines covered (89.25%)

468.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

22.22
/src/commands/tokens/exchange.js
1
'use strict';
2

3
const BoxCommand = require('../../box-command');
12✔
4
const { flags } = require('@oclif/command');
12✔
5

6
class TokensExchangeCommand extends BoxCommand {
7
        async run() {
8
                const { flags, args } = this.parse(TokensExchangeCommand);
×
9

10
                let client = this.client;
×
11
                if (flags.token) {
×
12
                        client = this.sdk.getBasicClient(flags.token);
×
13
                }
14
                if (flags['user-id']) {
×
15
                        client = this.sdk.getAppAuthClient('user', flags['user-id']);
×
16
                }
17

18
                let resource = null;
×
19
                if (flags['file-id']) {
×
20
                        resource = `https://api.box.com/2.0/files/${flags['file-id']}`;
×
21
                } else if (flags['folder-id']) {
×
22
                        resource = `https://api.box.com/2.0/folders/${flags['folder-id']}`;
×
23
                }
24

25
                let tokenInfo = await client.exchangeToken(args.scope.split(','), resource);
×
26

27
                this.output(tokenInfo.accessToken);
×
28
        }
29
}
30

31
TokensExchangeCommand.description = 'Get a token. Returns the service account token by default';
12✔
32

33
TokensExchangeCommand.args = [
12✔
34
        {
35
                name: 'scope',
36
                required: true,
37
                hidden: false,
38
                description: 'The scope(s) for the new token, separated by a comma if multiple are present'
39
        }
40
];
41

42
TokensExchangeCommand.flags = {
12✔
43
        ...BoxCommand.minFlags,
44
        'user-id': flags.string({
45
                char: 'u',
46
                description: 'Get a user token from a user ID',
47
                exclusive: ['token'],
48
        }),
49
        'file-id': flags.string({
50
                description: 'Scope the token to a specific file',
51
                exclusive: ['folder-id'],
52
        }),
53
        'folder-id': flags.string({
54
                description: 'Scope the token to a specific folder',
55
                exclusive: ['file-id'],
56
        }),
57
        token: flags.string({
58
                char: 't',
59
                description: 'Specify the token to exchange',
60
                exclusive: ['user-id'],
61
        })
62
};
63

64
module.exports = TokensExchangeCommand;
12✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc