bru run fails with OAuth2 authorization_code flow while Bruno Desktop works with the same collection
I have checked the following:
- [x] I have searched existing issues and found nothing related to my issue.
This bug is:
- [x] Making Bruno unusable for me.
- [ ] Slowing me down but I'm able to continue working.
- [ ] Annoying.
- [ ] This feature was working in a previous version but is broken in the current release.
Bruno version
4.2.0
π» Operating System
Windows
Specific OS Version / Distro
Windows
π Describe the bug
Bruno versions β’ Bruno Desktop: 4.2.0 β’ Bruno CLI: 4.1.0 OS β’ Windows
Example structure: MyBrunoCollection/ βββ opencollection.yml βββ environments/ β βββ test-env.yml βββ Service API/ βββ folder.yml <- parent folder-level OAuth2 auth βββ Scenario Group/ auth: inherit βββ Scenario-01/ auth: inherit βββ folder.yml <- child folder in hierarchy auth: inherit βββ StartQuote.yml auth: inherit βββ GetQuote.yml auth: inherit
OAuth2 authorization_code authentication works in Bruno Desktop, but the same collection fails with 401 Unauthorized when run via bru run in CLI. Desktop opens browser login and completes authentication successfully. CLI does not appear to complete token acquisition for the same auth configuration, and the request is sent without valid authorization. To reproduce
- Configure a collection/folder with OAuth2 Authorization Code flow.
- Use settings similar to: β’ authorizationUrl β’ accessTokenUrl β’ clientId β’ scope β’ callback_url: https://oauth.usebruno.com/callback β’ autoFetchToken: true
- Run successfully in Bruno Desktop.
- Run the same request/folder in CLI using bru run.
Example auth config
auth:
type: oauth2
flow: authorization_code
authorizationUrl: "
CLI command: bru run "Test Name" --env environment-file -r
Actual behavior CLI run returns 401 Unauthorized.
toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type toBrunoAuth failed: Unsupported auth type
My Test\Step-1 (401 Unauthorized) - 702 ms Tests β Status should be 200 expected 401 to equal 200 β StartQuote response should match body properties expected undefined to equal 'AboutToQuickQuote' My Test\Step-2 (401 Unauthorized) - 672 ms Tests β Status should be 200 expected 401 to equal 200 β response should match body properties expected undefined to equal '543766'
π Execution Summary βββββββββββββββββ¬βββββββββββββββ β Metric β Result β βββββββββββββββββΌβββββββββββββββ€ β Status β β FAIL β βββββββββββββββββΌβββββββββββββββ€ β Requests β 2 (2 Failed) β βββββββββββββββββΌβββββββββββββββ€ β Tests β 0/4 β βββββββββββββββββΌβββββββββββββββ€ β Assertions β 0/0 β βββββββββββββββββΌβββββββββββββββ€ β Duration (ms) β 2141 β βββββββββββββββββ΄βββββββββββββββ
Expected behavior CLI should either: 1. complete OAuth2 Authorization Code token acquisition, or 2. clearly indicate that interactive Authorization Code flow is not supported in CLI.
Notes β’ The same collection works in Bruno Desktop. β’ Adding callback_url: https://oauth.usebruno.com/callback allowed Desktop auth to work. β’ CLI still fails with 401 Unauthorized. β’ A bearer-token workaround works in CLI, but native authorization_code flow does not. Impact:
This blocks running the same authenticated collection in CI/CLI while it works in Desktop. This blocks running the collection in pipeline
π Steps to reproduce
OAuth2 authorization_code authentication works in Bruno Desktop, but the same collection fails with 401 Unauthorized when run via bru run in CLI. Desktop opens browser login and completes authentication successfully. CLI does not appear to complete token acquisition for the same auth configuration, and the request is sent without valid authorization. To reproduce
- Configure a collection/folder with OAuth2 Authorization Code flow.
- Use settings similar to: β’ authorizationUrl β’ accessTokenUrl β’ clientId β’ scope β’ callback_url: https://oauth.usebruno.com/callback β’ autoFetchToken: true
- Run successfully in Bruno Desktop.
- Run the same request/folder in CLI using bru run.
Example auth config
auth:
type: oauth2
flow: authorization_code
authorizationUrl: "
CLI command: bru run "Test Name" --env environment-file -r
π Collection to reproduce
No response
π· Screenshots/Live demo link
i would like to work on this issue. Can anyone assign me this?
@brunobragaw8t/ @brunohpaiva / @brunograsselli / @sid-bruno / @ved-bruno / @sachin-bruno / @sachin-thakur-bruno / @sanish-bruno / @Gopi-bruno / @gopu-bruno / @naman-bruno / @pooja-bruno / @utkarsh-bruno / @ravindra-bruno / @chirag-bruno @sanish-bruno @sanjaikumar-bruno / @shubh-bruno / @sharan-bruno / @aditya-bruno / @adwait-bruno @arpit-bruno
@iamrishu11 Is interested to work on this issue. Could you please take a look and assign him if everything seems okay
Hi @iamrishu11, you can surely work on this and raise a PR following the contributing guidelines. Once raised we'll review your PR and update you accordingly.
@dipeshinstanda, could you please help us with a screen recording of the OAuth working on the desktop and same time giving an error in CLI?
Hey @Rohan-Bruno , just wanted to confirm the intended scope of this issue. Should the CLI actually support completing the OAuth2 Authorization Code flow, or should it instead clearly indicate that interactive Authorization Code authentication is not supported in bru run?
@Rohan-Bruno Please find the requested recording:
https://github.com/user-attachments/assets/96399480-4662-41d6-b3b0-87407ede1207
@iamrishu11 : The CLI should support the OAuth 2.0 Authorization Code Flow. We're already receiving a 401 Unauthorized response, which confirms that authentication is currently not working.
At this point, the issue appears to be related to the authentication flow rather than the API functionality itself. Once the CLI is configured to authenticate correctly using the Authorization Code Flow, we can verify whether there are any additional issues.
Hi @Rohan-Bruno , Iβve opened a PR for this: https://github.com/usebruno/bruno/pull/9375
The PR adds real OAuth 2.0 Authorization Code support to bru run, including:
- inherited folder-level OAuth2 auth
- browser-based interactive sign-in
- PKCE and state validation
- localhost callback handling with a one-shot loopback listener
- pasted callback URL fallback for non-local callbacks such as
https://oauth.usebruno.com/callback - authorization-code exchange and refresh handling
- in-memory token reuse across requests sharing the same OAuth credentials
- avoiding repeated sign-in prompts after the same authorization failure
- clear behavior in non-interactive/headless environments instead of silently sending unauthenticated requests
I also added unit and end-to-end coverage with a mock IdP. The CLI and requests test suites pass, and the requests package builds successfully.
Electron/Desktop behavior is unchanged, and the CLI does not read or reuse Desktopβs OAuth token store.
Hi @dipeshinstanda, thank you for the screen recording! I wanted to check what youβre currently doing as a workaround for this issue.
@Rohan-Bruno : Currently, we are just running them only on Bruno desktop. But we want to create a pipeline on azure devops to run them automatically which requires an support on the cli.
Hi @dipeshinstanda, thank you for the details!
So Bruno CLI doesn't support the OAuth2 Authorization Code flow today. That grant needs someone to log in, consent through a browser. CLI is headless so there's no browser to show that screen.
The desktop app can do it because it opens a browser window, captures the token, and stores it locally, but the CLI runs as a separate process and doesn't read the desktop app's stored token.
For CLI/CI runs, OAuth2 works with the grants that don't need a browser which is Client Credentials and Password. If Authorization Code is required in automation, the usual workaround is to obtain a token out-of-band and pass it in (e.g. as a bearer token / variable).
About toBrunoAuth failed: Unsupported auth type: These aren't related to the 401. When you run bru run, the CLI first reads every file in your collection, not just the folder you're running. This warning appears when a file has an auth value Bruno doesn't recognize. Bruno then treats that file as having no auth and carries on. The desktop app reads the same files but doesn't display this warning, which is why you only see it in the terminal.
Supported values are:
auth: inheritauth:with atype:ofoauth2,bearer,basic,apikey,digest,ntlm,awsv4,wsse,oauth1orakamai-edgegrid- no
authline at all, which means no auth
Values are case-sensitive, so things like auth: Inherit, auth: none will trigger the warning. Fixing those entries in your other folders and requests should clear the messages.