8000 How to authenticate to the Provider target endpoint ? · Issue #540 · pact-foundation/pact-net · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How to authenticate to the Provider target endpoint ? #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rpbs opened this issue May 6, 2025 · 6 comments
Closed

How to authenticate to the Provider target endpoint ? #540

rpbs opened this issue May 6, 2025 · 6 comments
Labels
triage This issue is yet to be triaged by a maintainer

Comments

@rpbs
Copy link
rpbs commented May 6, 2025

Version information:

  • PactNet Version: 5.0.1
  • .Net Version: 8

Describe the bug
Not a bug but I'm not being able to pass Authorization with a Bearer to the header of the Pact Uri

Steps To Reproduce
I have a pact verifier, I need to be able to authenticate to the Provider Uri.

httpVerifier.WithHttpEndpoint(providerUri)

Then I'm calling Verify() method

Log Output
I'm getting 401

Could you guys help me to understand what I'm missing ?

@rpbs rpbs added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels May 6, 2025
@mefellows
Copy link
Member

Have you seen https://docs.pact.io/provider/handling_auth? There are some helpful tips on approaches here.

To clarify, do you want to authenticate to your Provider API, or the pact URI? i.e. is the 401 when connecting to your API or the location of the pact file (I think it's the former)?

@mefellows mefellows removed the bug Indicates an unexpected problem or unintended behavior label May 7, 2025
@rpbs
Copy link
Author
rpbs commented May 7, 2025

Thanks for your answer so far.

I believe what I want to authenticate to my provider api, which is my application running locally.

Image

@curtisstacey
Copy link

Yeah so the issue we have found is that we are able to run the consumer test and generate the json file and we are able to run the provider test and it worked but that was when the endpoint was set to allow anonymous, but once we set up the endpoint to require authentication, the consumer test still works but the provider test fails now betting a 401 error.

@rpbs
Copy link
Author
rpbs commented May 9, 2025

I was able to solve it, I will let you guys know on a next comment.

@adamrodger
Copy link
Contributor

You can use the WithHeader API to pass an authentication header if you want to keep authentication enabled in your provider.

I prefer to disable auth in the tests personally, but that feature is there in case you'd rather leave it on.

@rpbs
Copy link
Author
rpbs commented May 9, 2025

You can use the WithHeader API to pass an authentication header if you want to keep authentication enabled in your provider.

I prefer to disable auth in the tests personally, but that feature is there in case you'd rather leave it on.

Yeah that was part of the solution too.

I also understand that the Authorization bearer should part of the header and it would be part of pact as well.

I will close this ticket, thanks.

@rpbs rpbs closed this as completed May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants
0