Skip to content

"[400 Bad Request] unauthorized_client" after adding environment #154

@oneilep

Description

@oneilep

Description of the Issue

After following the Getting Started instructions and successfully adding a CLI environment using the config file obtained from my Box Developer console, box commands (e.g. box users:get) attempting to use the API fails with the message, "Unexpected API Response [400 Bad Request] unauthorized_client - This app is not authorized by the enterprise admin"

Versions Used

Box CLI: @box/cli/2.3.0 linux-x64 node-v10.16.0
Operating System: CentOS 6.10

Steps to Reproduce

Download the node.js x64 Linux binary from https://nodejs.org/en/download/
Run npm install --global @box/cli
Create New App in the Box Developer Console using "OAuth 2.0 with JWT (Server Authentication)"
Generate a public/private keypair and download the given config json file
Run box configure:environments:add PATH_TO_CONFIG_FILE - should output Successfully added CLI environment "default"
Run box users:get - unauthorized_client error occurs

Expected behavior: successfully authenticate and produce output similar to what is shown in https://github.com/box/boxcli#Usage

Error Message, Including Stack Trace

$ box users:get -v
box:@box/cli:hooks:init done +0ms
box init version: @oclif/command@1.5.5 argv: [ 'users:get', '-v' ] +0ms
box-cli:init Initializing Box CLI +0ms
box-cli:init Loaded settings { boxReportsFolderPath: '/home/oneilep/Documents/Box-Reports',
box-cli:init boxReportsFileFormat: 'txt',
box-cli:init boxDownloadsFolderPath: '/home/oneilep/Downloads/Box-Downloads',
box-cli:init outputJson: false } +5ms
box-cli:init Using environment default { clientId: 'redacted',
box-cli:init enterpriseId: 'redacted',
box-cli:init boxConfigFilePath:
box-cli:init '/home/oneilep/downloads/config.json',
box-cli:init hasInLinePrivateKey: true,
box-cli:init privateKeyPath: null,
box-cli:init name: 'default',
box-cli:init defaultAsUserId: null,
box-cli:init useDefaultAsUser: false,
box-cli:init cacheTokens: true } +4ms
box-cli:init Initialized client from environment config +74ms
box-cli:execute Starting execution command: users:get argv: [ '-v' ] +0ms
box-cli:execute Running framework error handler +320ms
box-cli:execute Handling re-thrown error in base command handler +41ms
Error: Unexpected API Response [400 Bad Request] unauthorized_client - This app is not authorized by the enterprise admin
at Object.buildResponseError (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/box-node-sdk/lib/util/errors.js:120:23)
at Object.buildUnexpectedResponseError (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/box-node-sdk/lib/util/errors.js:154:15)
at requestManager.makeRequest.then.response (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/box-node-sdk/lib/token-manager.js:226:19)
at tryCatcher (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/promise.js:694:18)
at Promise._fulfill (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/promise.js:638:18)
at Promise._settlePromise (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/promise.js:582:21)
at Promise._settlePromise0 (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/promise.js:694:18)
at Promise._fulfill (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/promise.js:638:18)
at /node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/bluebird/js/release/nodeback.js:42:21
at process.nextTick (/node/node-v10.16.0-linux-x64/lib/node_modules/@box/cli/node_modules/box-node-sdk/lib/api-request.js:347:3)
at process._tickCallback (internal/process/next_tick.js:61:11)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions