caitlin wardle
caitlin wardle

Reputation: 367

ASP.NET Core MVC : Okta integration

I'm creating an ASP.NET Core MVC application which uses Okta for authentication. I'm experiencing a very strange issue. My Okta sandbox works great, but when I switch to my Okta Production I get the following error:

IOException: IDX20807: Unable to retrieve document from: '[PII of type 'System.String' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'. HttpResponseMessage: '[PII of type 'System.Net.Http.HttpResponseMessage' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]', HttpResponseMessage.Content: '[PII of type 'System.String' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.

I set up the application the exact same in Okta production but it causes issues. Note when I switch to a different Okta integration I only change my Okta values in appSettings.json, (the issuer, clientId, clientSecret, and authority).

//appsettings.json

"Okta": {
  "Issuer": "https://Domain/oauth2/default",
  "ClientId": "hidden",
  "ClientSecret": "hidden",
  "CallbackPath": "/okta-auth",
  "Authority": "https://Domain/oauth2/default"
}

Startup.cs - ConfigureServices method:

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
     services.AddControllersWithViews();
     services.AddAuthorization();

     services.AddAuthentication(options =>
     {
         options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
         options.DefaultChallengeScheme = "okta";
     })
         .AddCookie(options =>
         {
         })

         // let users sign in with okta account
         .AddOpenIdConnect("okta", options =>
         {
             options.Authority = Configuration["Okta:Authority"];
             options.ClientId = Configuration["Okta:ClientId"];
             options.ClientSecret = Configuration["Okta:ClientSecret"];
             options.CallbackPath = Configuration["Okta:CallbackPath"];
             options.ResponseType = OpenIdConnectResponseType.Code;
         });
}

Note: my Program.cs also uses app.UseAuthorization();, app.UseAuthorization();.

I really don't understand what may be causing this.

Upvotes: 1

Views: 567

Answers (1)

caitlin wardle
caitlin wardle

Reputation: 367

I got it!!

So its because I had /oauth2/default attached to the authority and I don't have the paid feature for that. Removing it solved my issue.

Upvotes: 0

Related Questions