Skip to content
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

KiotaClientFactory doesn't build a httpclient that will work because it is missing auth middleware #270

Closed
darrelmiller opened this issue Dec 19, 2023 · 6 comments · Fixed by #430
Assignees
Labels
area:http enhancement New feature or request WIP

Comments

@darrelmiller
Copy link
Member

https://github.com/microsoft/kiota-http-dotnet/blob/eb76ee893324bd373462e98dfdafeba95762feff/src/KiotaClientFactory.cs#L36

This issue is related to this ADR microsoft/kiota#3941

We need to think about building an AuthHandler middleware that can use our Kiota Auth Providers so that we can have native HttpClient experiences. Otherwise, we can't satisfy this ADR microsoft/kiota#3200

@baywet baywet added the enhancement New feature or request label Dec 20, 2023
@baywet
Copy link
Member

baywet commented Dec 20, 2023

Capture notes from our discussion, we could add:

  • A middleware that would accept an authentication provider as a parameter, copy the URL (and www-authenticate) into the request information, call the authenticate method, copy the relevant fields in the request message. And this only if the request message doesn't already have the relevant fields or has a www-authenticate header.
  • another method in the client factory that'd accept an authentication provider, and set default middleware handler + this new one.
  • refactor the code so CAE handling is not duplicated between request adapter and this new middleware.

We could consider moving all the authentication considerations out of the request adapter, but that creates two potential issues we designed around by adding it in the request adapter:

  • http clients are not portable anymore between different APIs
  • it's easier to forget to configure the authentication on the http client, and then have calls fail.

@darrelmiller, would you mind putting together a spec for this middleware handler in the SDK design repository please?

@baywet
Copy link
Member

baywet commented Dec 20, 2023

Related microsoft/kiota-http-go#130

@andrueastman
Copy link
Member

Transferring issue as part of #238

@baywet
Copy link
Member

baywet commented Sep 5, 2024

authored microsoftgraph/msgraph-sdk-design#111 to help move this along

@lvde0
Copy link

lvde0 commented Sep 12, 2024

I stumbled upon this issue since I have a custom "Token Refresh" middleware that tries to re-authenticate the request with the refreshed token. I was wondering if it's possible to access the IAuthenticationProvider somehow to do that? I mean I can still manually tweak the authorization header, but I think it would be cleaner to go via IAuthenticationProvider.

@baywet
Copy link
Member

baywet commented Sep 12, 2024

currently it's not, but with the new factory we'd be adding with this work, you could at least access it while initializing the middleware, and pass it to your custom middleware implementation.
We started the work in java microsoft/kiota-java#1562

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:http enhancement New feature or request WIP
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants