Add Login to Your ASP.NET Core MVC App

Add Login to Your ASP.NET Core MVC App

This tutorial walks you through adding simple authentication and authorization to your ASP.NET Core application using Okta.

Abhishek Chandra

On clicking of Login its not redirecting to Okta page.Instead its giving error in AccountController on below line.

return Challenge(OktaDefaults.MvcAuthenticationScheme)

Error is:
HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()

IOException: IDX20804: Unable to retrieve document from: ‘[PII is hidden]’.
Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(string address, CancellationToken cancel)

InvalidOperationException: IDX20803: Unable to obtain configuration from: ‘[PII is hidden]’.
Microsoft.IdentityModel.Protocols.ConfigurationManager<t>.GetConfigurationAsync(CancellationToken cancel)

Sanjeev Thapa

Any solution to this. I also have the same error.

leebrandt

I just went through the tutorial and had no problems. Do you have code or git repo that you can share?

Vinay Kumar

Using AddOktaMvc middleware, how to set ‘AccessDeniedPath’ ?

Randall Eike

I got the error two when I had incorrect information in the appsettings.json. Specifically, I had the wrong Domain. Once I fixed that, it worked.

Rohan Sampat (Rom4ster)

I keep getting a stupid login loop. What the hell, I see on Okta that I successfully logged in but the damn thing will keep repeating to the login screen because its not returning

Matt Raible

What browser are you using? Can you try a different browser, or look in your developer console and see if there’s any errors.

Don’t worry

How can someone extend the okta member model to add more fields?

Matt Raible

This blog post shows how to add custom attributes to a user’s profile. Please let me know if this doesn’t work for you.