Skip to main content
Question

I cannot login with BOX CLI using headless

  • September 24, 2026
  • 0 replies
  • 5 views

Hi,

I’m trying to use BOX CLI version @box/cli/4.10.1 linux-x64 node-v24.21.0
in headless mode.

I can access box using box cli and validating through a local browser

If I try headless I get an error.

These are the steps.

box login --code

? How would you like to authenticate?
[1] Log-in as a Box user (OAuth)
[2] Use a Box Platform App
[q] Quit
? Enter 1, 2, or q: 1




I paste in the URL given into a broswer on another computer and click Grant Access. This redirects to a localhost IP which includes the code and state. Similar to this 

http://localhost:3000/callback?state=12345678901234567890123456789012&code=ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF

I enter the state and the code into the box cli  and get 

Login failed: Failed to exchange auth code for tokens.

Can anyone help?