okta / okta-idx-dotnet

okta-idx-dotnet
https://github.com/okta/okta-idx-dotnet
Other
8 stars 19 forks source link

NullReferenceException in Sample #195

Open Mark-Good opened 1 year ago

Mark-Good commented 1 year ago

Describe the bug?

I configured the sample app called embedded-sign-in-widget according to Installation & Running The App. But when I run the app and try to open the Sign In Widget page, I get NullReferenceException: Object reference not set to an instance of an object. Okta.Idx.Sdk.Configuration.IdxConfigurationValidator.Validate(IdxConfiguration configuration)

I see that the accounts controller takes IIdxClient in its constructor, and the following DI is set up in Program.Main: builder.Services.AddScoped<IIdxClient, IdxClient>();

IdxClient has two constructors. One empty constructor and that takes three parameters, including IdxConfiguration. All of them default to null. It appears that configuration is null when dependency injected.

What is expected to happen?

The sample should run after following Installation & Running The App.

What is the actual behavior?

NullReferenceException: Object reference not set to an instance of an object. Okta.Idx.Sdk.Configuration.IdxConfigurationValidator.Validate(IdxConfiguration configuration)

Reproduction Steps?

  1. Follow the steps in Installation & Running The App.
  2. Run the application
  3. Click the Sign In link

Additional Information?

No response

.NET Version

7.0.102

SDK Version

Okta.Idx.Sdk 2.2.8 Okta.AspNetCore 4.4.2

OS version

No response

reykollab commented 1 year ago

Hello @Mark-Good, I also got into the same issue. Have you tried adding the Okta configuration file? Here are the steps: https://github.com/okta/okta-idx-dotnet/blob/master/README.md#configuration-reference

If you're using IIS Express, the okta.yaml file should be placed in C:\Program Files\IIS Express\okta.yaml