okta / okta-sdk-dotnet

A .NET SDK for interacting with the Okta management API, enabling server-side code to manage Okta users, groups, applications, and more.
Other
160 stars 100 forks source link

Newtonsoft.Json.JsonReaderException : Unexpected character encountered while parsing value: <. Path '', line 0, position 0. #544

Closed PrakashKumar-27 closed 2 years ago

PrakashKumar-27 commented 2 years ago

Describe the bug?

I am using the below code, i am using the private key to communicate. services.AddSingleton(new OktaClient(new OktaClientConfiguration { OktaDomain = Configuration.GetValue("Okta:Domain"), AuthorizationMode = AuthorizationMode.PrivateKey, ClientId = Configuration.GetValue("Okta:ClientId"), Scopes = new List { "okta.users.read", "okta.groups.read", "okta.groups.manage", "okta.users.manage" }, PrivateKey = new JsonWebKeyConfiguration(Configuration.GetValue("Okta:PrivateKey"))
}));

But i am getting this error

What is expected to happen?

I should able to communicate to Okta API through SDK

What is the actual behavior?

Throwing error "Unexpected character encountered while parsing value: W. Path '', line 0, position 0."

Reproduction Steps?

Install Okta SDK in .netcore3.1 and create the private key from service app in okta then try

Additional Information?

No response

.NET Version

netcoreapp3.1

SDK Version

5.6.0

OS version

Windows 10 Enterprise - 20H2 64-bit operating system, x64-based processor

bryanapellanes-okta commented 2 years ago

@PrakashKumar-27 Thanks for reaching out! To further help us reproduce the issue to determine how to fix, may I have you provide a sample project and specific steps to reproduce? I'm investigating further, a project with detailed steps to reproduce will be extremely helpful.

bryanapellanes-okta commented 2 years ago

@PrakashKumar-27 I've not been able to reproduce the issue as you've described; I suspect the exception is coming from the constructor of the JsonWebKeyConfiguration object. Internally it expects json that is used to populate its properties, the error implies that the supplied value cannot be parsed.

I suggest reaching out to our support team at developers@okta.com - they will be able to work with you directly and discuss details about your configuration in a less public manner.

PrakashKumar-27 commented 2 years ago

Hi @bryanapellanes-okta,

Thanks for responding, actually this is working fine with net5.0, but throwing error in .net core 3.1 version.

Thanks, PK

PrakashKumar-27 commented 2 years ago

Hi @bryanapellanes-okta,

In JsonWebKeyConfiguration while initializing no error is throwing in startup.cs but while calling the Okta Client it's throwing error.

Thanks in Advance, Prakash Kumar

bryanapellanes-okta commented 2 years ago

Closing due to inactivity.