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

SDK: Errors from oauth responses are not deserialized properly in .NET SDK #76

Open
p89 opened this issue Jul 31, 2024 · 0 comments
Open
Assignees
Labels

Comments

@p89
Copy link

p89 commented Jul 31, 2024

v. 1.51.0

Hi Team, during integration of this library I've found out a contract mismatch between the Error & Errors classes and the sample error responses from endpoints like oauth2/token.

Example error message from fusionAuth service:

{
    "error": "invalid_grant",
    "error_description": "The user credentials are invalid.",
    "error_reason": "invalid_user_credentials"
}

Error.cs

public class Error {

    public string code;

    public IDictionary<string, object> data;

    public string message;

    public Error with(Action<Error> action) {
      action(this);
      return this;
    }
  }

The DefaultRestClient always return null values as errors:

if (clientResponse.statusCode >= 300)
            clientResponse.errorResponse = JsonConvert.DeserializeObject<Errors>(result.Content.ReadAsStringAsync().Result, DefaultRESTClient.SerializerSettings);

Steps to reproduce:

Use the following method with incorrect credentials and try to read the errors:

Task<ClientResponse<AccessToken>> ExchangeUserCredentialsForAccessTokenAsync(
      string username,
      string password,
      string client_id,
      string client_secret,
      string scope,
      string user_code);
@linear linear bot added DX C# labels Aug 28, 2024
@synedra synedra self-assigned this Dec 10, 2024
@synedra synedra changed the title Errors from oauth responses are not deserialized properly SDK: Errors from oauth responses are not deserialized properly in .NET SDK Dec 10, 2024
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

2 participants