microsoft / kiota-dotnet

Abstractions library for the Kiota generated SDKs in dotnet
https://aka.ms/kiota/docs
MIT License
37 stars 34 forks source link

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

Closed darrelmiller closed 1 day ago

darrelmiller commented 10 months ago

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

This issue is related to this ADR https://github.com/microsoft/kiota/issues/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 https://github.com/microsoft/kiota/issues/3200

baywet commented 10 months ago

Capture notes from our discussion, we could add:

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:

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

baywet commented 10 months ago

Related https://github.com/microsoft/kiota-http-go/issues/130

andrueastman commented 4 months ago

Transferring issue as part of https://github.com/microsoft/kiota-abstractions-dotnet/issues/238

baywet commented 2 months ago

authored https://github.com/microsoftgraph/msgraph-sdk-design/pull/111 to help move this along

lvde0 commented 1 month ago

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 commented 1 month ago

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 https://github.com/microsoft/kiota-java/pull/1562