Problem with GetConfigurationOrDefault Method in Okta

Hi,
I’m experiencing a similar issue to what is discussed in
GetConfigurationOrDefault throwing Object reference not set to an instance of an object.

The Okta.AspNetCore version that I am on is 4.6.1

Here’s the piece of code I have to get user details. While I do receive the user details, I also encounter the above exception, which seems to bypass but still gives me the result.

var oktaConfig = new Configuration()
{
Token = configuration[“OktaToken”],
OktaDomain = configuration[“OktaDomain”],
};

UserApi = new UserApi(oktaConfig);
var user = UserApi.GetUserAsync(“test.user@test.com”).Result;
var name = user.Profile.DisplayName;

Has anyone found a solution for this issue? Any guidance would be greatly appreciated!

Regards.

Thanks for posting this. I’m having the same problem. My code is the same as yours, and it was based on sample code I found in the forums.

When I run the solution, Visual Studio breaks at the GetAllProperties() method inside ConfigurationBinder.cs because type is null. I can continue through the errors and it will eventually run, however I’m not sure if the results are accurate.

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Microsoft.Extensions.Configuration.Binder
StackTrace:
at Microsoft.Extensions.Configuration.ConfigurationBinder.GetAllProperties(Type type) in /_/src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs:line 654

Furthermore, the calling line in the OKTA SDK is Okta.Sdk.Client.Configuration.cs, Line 594, GetConfigurationOrDefault().
That line reads:
configurationBuilder.Build().GetSection("okta").GetSection("client") .Bind(configuration);

The line that calls that is line 39 in Okta.Sdk.Api.UserApi():
configuration = Okta.Sdk.Client.Configuration.GetConfigurationOrDefault(configuration);

I can consistently reproduce this so if any OKTA dev wants to reach out, I’ll be glad to help.

.NET 8.0
OKTA SDK: 8.0.1