Last post Apr 20, 2020 02:25 AM by Brando ZWZ
Member
52 Points
172 Posts
Apr 16, 2020 09:46 AM|IamGuy84|LINK
Dear folks,
I am using Asp.net core with SPA (Angular). I have created app registration with authentication on Azure portal as below:
In appsettings.json:
"AzureAd": { "Instance": "https://login.microsoftonline.com/", "Domain": "XXXX.onmicrosoft.com", "TenantId": "2c614b94-XXXX-408e-8800-XXXXXX", "ClientId": "894782b8-XXXX-4214-976f-XXXXXX", "CallbackPath": "/signin-oidc" },
In Sartup.cs:
................................... static readonly string _RequireAuthenticatedUserPolicy = "RequireAuthenticatedUserPolicy"; public void ConfigureServices(IServiceCollection services) { services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddAuthentication(AzureADDefaults.AuthenticationScheme) .AddAzureAD(options => Configuration.Bind("AzureAd", options)); services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options => { options.Authority = options.Authority + "/v2.0/"; // Microsoft identity platform options.TokenValidationParameters.ValidateIssuer = false; // accept several tenants (here simplified) }); services.AddAuthorization(o => o.AddPolicy(_RequireAuthenticatedUserPolicy, builder => builder.RequireAuthenticatedUser())); ................ }
I run the project and I am getting error message and it says as below:
Could you please help to resolve this issue? I am waiting for your response. Thanks in advance
Star
9831 Points
3120 Posts
Apr 20, 2020 02:25 AM|Brando ZWZ|LINK
Hi IamGuy84,
As far as I know, if you want to angular to login with AAD, you should AAD angular library.
More details about how to use it , you could refer to below article.
https://docs.microsoft.com/en-us/azure/active-directory/develop/sample-v2-code#single-page-applications
Best Regards,
Brando
Member
52 Points
172 Posts
Azure Ad problem with CORS policy
Apr 16, 2020 09:46 AM|IamGuy84|LINK
Dear folks,
I am using Asp.net core with SPA (Angular). I have created app registration with authentication on Azure portal as below:
![]()

In appsettings.json:
In Sartup.cs:
I run the project and I am getting error message and it says as below:

Could you please help to resolve this issue?
I am waiting for your response.
Thanks in advance
Star
9831 Points
3120 Posts
Re: Azure Ad problem with CORS policy
Apr 20, 2020 02:25 AM|Brando ZWZ|LINK
Hi IamGuy84,
As far as I know, if you want to angular to login with AAD, you should AAD angular library.
More details about how to use it , you could refer to below article.
https://docs.microsoft.com/en-us/azure/active-directory/develop/sample-v2-code#single-page-applications
Best Regards,
Brando