Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

IAccessTokenProvider is not being registered in Microsoft Graph v5 SDK

$
0
0

We have been following the Microsoft Graph API example on their website for Graph API Version 5. We are running a Blazor web application using ASP.NET Core 9.

It can be found here...

https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/graph-api?view=aspnetcore-9.0&pivots=graph-sdk-5#call-graph-api-from-a-component-using-a-named-httpclient

Everything builds as expected - and the code we are using is coming straight out of their examples. All our packages (the 4 listed in the example for Graph API and Access Library (MSAL) etc... are all installed using the latest versions of each. We also have Microsoft.Graph installed (the latest version).

When we run this we get an exception when it attempts to build the IoC container (default .NET Core container). this happens as soon as we call Build on the container after registrations.

System.AggregateExceptionHResult=0x80131500Message=Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.Kiota.Abstractions.Authentication.IAuthenticationProvider Lifetime: Scoped ImplementationType: Summit.UI.Graph.GraphClientExtensions+GraphAuthenticationProvider': Unable to resolve service for type 'Microsoft.AspNetCore.Components.WebAssembly.Authentication.IAccessTokenProvider' while attempting to activate 'Summit.UI.Graph.GraphClientExtensions+GraphAuthenticationProvider'.)Source=Microsoft.Extensions.DependencyInjectionStackTrace:at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)at Microsoft.Extensions.Hosting.HostApplicationBuilder.Build()at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build()at Summit.UI.Program.d__0.MoveNext() in C:\gitwf\Summit.UI\Summit.UI\Program.cs:line 57

This exception was originally thrown at this call stack:[External Code]

Inner Exception 1:InvalidOperationException: Error while validating the service descriptor 'ServiceType: Microsoft.Kiota.Abstractions.Authentication.IAuthenticationProvider Lifetime: Scoped ImplementationType: Summit.UI.Graph.GraphClientExtensions+GraphAuthenticationProvider': Unable to resolve service for type 'Microsoft.AspNetCore.Components.WebAssembly.Authentication.IAccessTokenProvider' while attempting to activate 'Summit.UI.Graph.GraphClientExtensions+GraphAuthenticationProvider'.

Inner Exception 2:InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Components.WebAssembly.Authentication.IAccessTokenProvider' while attempting to activate 'Summit.UI.Graph.GraphClientExtensions+GraphAuthenticationProvider'.

I did this with a blank project (.net version 9) out of the box as well and ran into the same issue.

It looks like it's just not getting registered.

We attempted rolling back to version 8 then downgrading to an older version of the API - I also attempted to pull in the Kiota version which is apparently really wants us to use in spite of the defaults being the ones forced to use in the example (I didn't see the implementation of the default token provider in DotPeek either - a good indicator that something big changed here maybe?).

We also tried abandoning the SDK and just going straight HTTP client - but it still needs to have the MSAL stuff in there for the token according to their example - that's where we hit this wall again (which I thought might happen - but i was willing to take 30 minutes to try this quick to verify it was not going to help).


Viewing all articles
Browse latest Browse all 4839

Trending Articles