Git Product home page Git Product logo

Comments (4)

AaronAtDuo avatar AaronAtDuo commented on June 8, 2024

@JoelDKraft We got the same request from an internal Duo team that uses this client, which led to 1d94501 which is not in a release yet. Does that change look like it would suit your use case? If so, I can work on getting a release out soon.

from duo_universal_csharp.

JoelDKraft avatar JoelDKraft commented on June 8, 2024

That takes care of half of what I described, which is being able to determine if there was an HTTP exception thrown by the API call. If there is no exception, but the API returns FAIL, that is information is still not available.

Now that you've added that parameter, maybe it makes sense to throw a DuoException when the health check comes back negative, as well?

 var response = await DoPost<HealthCheckResponse>(healthCheckUrl, parameters);
 if (response.Stat == "OK") return true;
 if (!handleException) throw new DuoException($"{response.Code} {response.Message} {response.MessageDetail}");
return false;

from duo_universal_csharp.

AaronAtDuo avatar AaronAtDuo commented on June 8, 2024

@JoelDKraft thanks for the clarification. I'll look into it.

from duo_universal_csharp.

JoelDKraft avatar JoelDKraft commented on June 8, 2024

I'm going to throw one more comment in here: the same type of thing happens in DoPost.

The following line throws an exception if the call does not return a 200 code...
// This will throw an HttpRequestException if the result code is not in the 200s
//httpResponse.EnsureSuccessStatusCode();

So in my case, I got the following exception:
Response status code does not indicate success: 400 (Bad Request)

The problem here is that the API actually returned a response with an error message, and I really needed to know that response to figure out what was going wrong. But this blanket exception again removed any chance of me seeing that underlying error.

Replacing it with something like this would let you actually see the API response.
if (!httpResponse.IsSuccessStatusCode) throw new DuoException($"{httpResponse.StatusCode}: {httpResponse.Content.ReadAsStringAsync().Result}");

I was able to get this server response, and now I know what is wrong:
{"error": "invalid_grant", "error_description": "The provided authorization grant (e.g., authorization code) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."}

I would probably not just dump in the raw JSON, but you get the idea...

from duo_universal_csharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.