bruno icon indicating copy to clipboard operation
bruno copied to clipboard

[Bug] Cannot override Collection Basic Auth with request specific Bearer Token

Open kpau opened this issue 2 years ago • 5 comments

I have a collection with Auth set to Basic Auth: image

In the collection there is a GET Request, which has a Bearer Token auth: image

When I execute the request and observe the "Timeline" tab on the right, I see that it still uses the Basic Auth credentials: image

I would expect that it will use the Bearer Token Auth specified in the request.

If I disable the Collection Auth (set it to No Auth), then the request correctly uses the Bearer Token auth: image

I am using Bruno v1.1.1

kpau avatar Nov 13 '23 17:11 kpau

You can fix this by using the Collection's Headers tab and add a Authorization header while setting its value to: Bearer {{accessToken}}

Then every request inside of this collection will use that same header for its authentication. This is not the most ideal solution but fortunately others have voiced this issue too in #816 and it should be fixed in #907.

n00o avatar Nov 13 '23 19:11 n00o

@kpau if you're able, please try out my feature branch https://github.com/btgs-0/bruno/tree/feature/auth-from-collection and let me know if it works for you

btgs-0 avatar Nov 13 '23 22:11 btgs-0

@n00o , Thanks for the info. But my issue is a bit different compared to #816. I understand that No Auth uses Collection auth, but in my case I am explicitly setting another type of Auth and it is still using the Collection auth. The issues are related so the root cause might be the same.

@btgs-0 , Thanks for the PR. If I have time today, I'll test the branch.

Even if the issue is fixed with this PR, it is good to have both issues documented for future reference.

Edit: I tested the PR and it resolves my issue. Thanks!

kpau avatar Nov 14 '23 07:11 kpau

thanks for testing my PR @kpau. And thanks @n00o for connecting the dots, my PR incidentally fixes this issue by making the collection auth inheritance explicit

btgs-0 avatar Nov 14 '23 19:11 btgs-0

It appears that https://github.com/usebruno/bruno/pull/1667 addresses this by explicit requirement of inheritance.

karloluis avatar Mar 07 '24 09:03 karloluis

Closing this issue as the PR implementing the feature has already been merged. Check out this https://github.com/usebruno/bruno/issues/816#issuecomment-2202065577 comment demonstrating the PR's behavior.

sanjai0py avatar Jul 02 '24 10:07 sanjai0py