Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with GetConfigurationOrDefault Method in Okta #766

Open
pancholi24-usi opened this issue Jan 7, 2025 · 2 comments
Open

Problem with GetConfigurationOrDefault Method in Okta #766

pancholi24-usi opened this issue Jan 7, 2025 · 2 comments
Assignees
Labels

Comments

@pancholi24-usi
Copy link

pancholi24-usi commented Jan 7, 2025

Describe the bug?

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(“[email protected]”).Result;
var name = user.Profile.DisplayName;

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

What is expected to happen?

Call the OKTA API without any error

What is the actual behavior?

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

Reproduction Steps?

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

Additional Information?

No response

.NET Version

.net 6.0

SDK Version

Okta.AspNetCore version is 4.6.1
Okta.Sdk version tried 8.0.1 and 9.0.3(latest) both have same issue
Okta.Auth.Sdk version is 2.0.5

OS version

No response

@bryanapellanes-okta
Copy link
Contributor

@pancholi24-usi Thanks for reporting this! I've entered an internal issue for tracking and prioritization. OKTA-852181

@pancholi24-usi
Copy link
Author

Thanks for responding on our issue request. Is there any ETA for this and priority defined ? We are currently in holding pattern due to this so want to know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants