You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello i'm facing issues usign the authProvider to use with my Kiota Client API,
i'm using a Blazor Server App ,
My authentication is buld like this :
builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(options =>
{
builder.Configuration.Bind("AzureAd", options);
// Request a refresh_token.
options.Scope.Add(OpenIdConnectScope.OfflineAccess);
// Store the refresh_token.
options.SaveTokens = true;
options.Events.OnTokenValidated += eventArgs =>
{
Console.WriteLine("OnTokenValidated");
var idToken = eventArgs.ProtocolMessage.IdToken;
//Acces to the access_token from here ???
return Task.CompletedTask;
};
options.SaveTokens = true;
})
.EnableTokenAcquisitionToCallDownstreamApi()
.AddInMemoryTokenCaches();
I'm using a CustomTokenCredential configuration
private readonly string _accessToken;
public CustomTokenCredential(string accessToken)
{
_accessToken = accessToken;
}
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
{
return new AccessToken(_accessToken, DateTimeOffset.UtcNow.AddHours(1));
}
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
{
// Return the token asynchronously.
return await Task.FromResult(new AccessToken(_accessToken, DateTimeOffset.UtcNow.AddHours(1)));
}
}
But i m not able to connect using that DI configuration :
var tokenCredential = new CustomTokenCredential(AccesToken);
var provider = new AzureIdentityAuthenticationProvider(tokenCredential);
builder.Services.AddSingleton<IRequestAdapter, HttpClientRequestAdapter>(adapter =>
{
var authProvider = new AzureIdentityAuthenticationProvider(tokenCredential);
return new HttpClientRequestAdapter(authProvider)
{
BaseUrl = basePath,
};
});
builder.Services.AddSingleton<MyClient>();
Could you help me resolve this or show me the proper way to approach it?
The text was updated successfully, but these errors were encountered:
Hello i'm facing issues usign the authProvider to use with my Kiota Client API,
i'm using a Blazor Server App ,
My authentication is buld like this :
I'm using a CustomTokenCredential configuration
But i m not able to connect using that DI configuration :
Could you help me resolve this or show me the proper way to approach it?
The text was updated successfully, but these errors were encountered: