i'll check it
this is the code in AuthServerModule.cs in ConfigureServices(context)
....
context.Services.AddAuthentication().AddMicrosoftIdentityWebApp(configuration.GetSection("AzureAd"));
context.Services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options =>
{
options.Authority = "https://login.microsoftonline.com/" + configuration["AzureAd:TenantId"] + "/v2.0/";
options.ClientId = configuration["AzureAd:ClientId"];
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.CallbackPath = configuration["AzureAd:CallbackPath"];
options.ClientSecret = configuration["AzureAd:ClientSecret"];
options.RequireHttpsMetadata = false;
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.SignInScheme = IdentityConstants.ExternalScheme;
options.Scope.Add("email");
options.Scope.Add("openid");
options.Scope.Add("offline_access");
options.Scope.Add("profile");
options.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "sub");
});
....
My application is Blazor Web App.
I need to use the token also in the API controllers and in the front end.
Probably i need to store the received token but i can't understand how to do it.
Hi berkansasmaz, i solved the issue,
I have only one problem. I need to save and store the AD access_token but is always blank. How i have to do and where? In the AuthServer or in the Host?
I need to use use it in the Blazora Page.
Hi Berkansasmaz,
i have already test the four resource with no success.
If i use AddOpenIdConnect it work but i have to use AddMicrosoftIdentityWebApp
This is my code:
context.Services.AddAuthentication().AddMicrosoftIdentityWebApp(options =>
{
options.Instance = "https://login.microsoftonline.com/";
options.TenantId = configuration["AzureAd:TenantId"];
options.ClientId = configuration["AzureAd:ClientId"];
options.ClientSecret = configuration["AzureAd:ClientSecret"];
//options.CallbackPath = configuration["AzureAd:CallbackPath"];
//options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.ResponseType = "code";
options.RequireHttpsMetadata = true;
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add("email");
options.Scope.Add("openid");
options.Scope.Add("offline_access");
options.Scope.Add("profile");
//options.Scope.Add("https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All");
//options.Scope.Add("https://analysis.windows.net/powerbi/api/Workspace.Read.All");
options.SignInScheme = IdentityConstants.ExternalScheme;
options.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "sub");
options.Events = new OpenIdConnectEvents
{
OnTokenValidated = context =>
{
// Log token claims
var claims = context.Principal.Claims;
foreach (var claim in claims)
{
Console.WriteLine($"{claim.Type}: {claim.Value}");
}
return Task.CompletedTask;
},
OnAuthenticationFailed = context =>
{
Console.WriteLine($"Authentication failed: {context.Exception.Message}");
return Task.CompletedTask;
}
};
});
When i login i get the following error:
2025-06-26 21:32:53.327 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessRequestContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ResolveRequestUri. 2025-06-26 21:32:53.327 +02:00 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ResolveRequestUri. 2025-06-26 21:32:53.327 +02:00 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.OpenIddictServerHandlers+InferEndpointType. 2025-06-26 21:32:53.327 +02:00 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by Volo.Abp.Account.Web.Pages.Account.OpenIddictImpersonateInferEndpointType. 2025-06-26 21:32:53.327 +02:00 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ValidateTransportSecurityRequirement. 2025-06-26 21:32:53.327 +02:00 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ValidateHostHeader. 2025-06-26 21:32:53.328 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ValidateHostHeader. 2025-06-26 21:32:53.328 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+EvaluateValidatedTokens. 2025-06-26 21:32:53.328 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromAuthorizationHeader. 2025-06-26 21:32:53.328 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromBodyForm. 2025-06-26 21:32:53.328 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromQueryString. 2025-06-26 21:32:53.328 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateRequiredTokens. 2025-06-26 21:32:53.328 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was marked as rejected by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateRequiredTokens. 2025-06-26 21:32:53.328 +02:00 [DBG] AuthenticationScheme: OpenIddict.Validation.AspNetCore was not authenticated.
I have to use Microsoft.Web.Identity as method of atuhentication
Hi,
i have to add Microsoft Web Identity as External Login Provider but i'm not able to understand where to customize the code. Do you have an example?
I'am creating a blazor web app to show some PowerBI reports in a PowerBI page. I'am using separate authserver.
I need to login to azure, store the the token, open the blazor page, retrieve the token, retrieve the report by the PowerBiServiceApi and show it in the page.
Someone can guide me to do this?
I've already tried the solution by @Anjali_Musmade on the question 5720 but with no success in Blazor Web App.
By the suite I had generated a crud page.
I create a lookup navigation with type "Modal" but the source code is always for "TypeAhead"
How to create a pick up modal?
We have the same problem.
I receive this message when compiling:
Gravità Codice Descrizione Progetto File Riga Stato eliminazione Errore (attivo) NU1301 Non è possibile caricare l'indice del servizio per l'origine https://nuget.abp.io/xxxxxxxxx-xxxxxxx-xxxxxxx/v3/index.json. Volo.EasyCrm.Domain.Shared, Volo.EasyCrm.Domain.Shared, Volo.EasyCrm.Domain.Shared, Volo.EasyCrm.Domain.Shared, Volo.EasyCrm.Domain.Shared C:\ABP\EasyCRM\aspnet-core\src\Volo.EasyCrm.Domain.Shared\Volo.EasyCrm.Domain.Shared.csproj 1
Is NuGet server down?