<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z0000AJSzJVCQ1Okta Classic EngineAPI Access ManagementAnswered2025-02-26T23:49:53.000Z2025-02-26T19:43:32.000Z2025-02-26T23:49:53.000Z
Problem with GetConfigurationOrDefault Method in Okta

I’m experiencing a similar issue to what is discussed in

(https://devforum.okta.com/t/getconfigurationordefault-throwing-object-reference-not-set-to-an-instance-of-an-object/28968).

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!

 

ERROR

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);

 

SDK Info

Okta.AspNetCore version is 4.6.1

Okta.Sdk version tried 9.1.1 (Older version also have same issue)

Okta.Auth.Sdk version is 2.0.5

.NET version 6.0 (upgraded from .net4.8 to .net6.0)

OS: Windows

Project Template used: any template but currently using .NET Core.

IDE: Visual Studio 2022


  • Paul S. (Okta, Inc.)

    Hello @VaidehiP.83594 (Customer)​ Thank you for posting on our Community page!

     

    This question is more appropriate for our dedicated Okta Developer Forum.

    My advice would be to reach out via devforum.okta.com to take advantage of their expertise.

    While we'll do our best to answer all of your questions here, this medium is more inclined towards Okta core products and features (non-developer work).

     

    Thank you for reaching out to our Community and have a great day!

    --

    Help others in the community by liking or hitting Select as Best if this response helped you.

    The new Okta Help Center YouTube channel is your go-to resource for tips, troubleshooting, and best practice videos. Subscribe today

    Expand Post
This question is closed.
Loading
Problem with GetConfigurationOrDefault Method in Okta