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

box / boxcli / 10810816048

11 Sep 2024 11:36AM UTC coverage: 86.569% (-0.05%) from 86.616%
10810816048

Pull #542

github

web-flow
Merge a647aad97 into 0ed1618f5
Pull Request #542: docs: Add examples to file/folder metadata commands

1191 of 1536 branches covered (77.54%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 4 files covered. (100.0%)

1 existing line in 1 file now uncovered.

4281 of 4785 relevant lines covered (89.47%)

310.32 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');
8✔
4
const { flags } = require('@oclif/command');
8✔
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';
8✔
32

33
TokensExchangeCommand.args = [
8✔
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 = {
8✔
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;
8✔
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