Comments (4)
@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.
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.
@JoelDKraft thanks for the clarification. I'll look into it.
from duo_universal_csharp.
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)
- DUO_API_CERT_SERVER in tests expired today HOT 3
- JSON decode error parsing `is_encryption_enabled` HOT 4
- Intermittent API call failures due to no leeway in nbf field of JWT HOT 5
- Unable to run Sample HOT 4
- Add documentation on how to call from ASP.NET HOT 4
- Failed Health Check Responses Deserialize to null HOT 4
- TestCertPinning tests failing because MICROSOFT_COM_CERT_SERVER is expired HOT 1
- Some way to restrict or suggest phone numbers for a user? HOT 2
- strong naming the component HOT 5
- Microsoft.IdentityModel.JsonWebTokens Issue HOT 10
- Cors error HOT 6
- IDX10720: Unable to create KeyedHashAlgorithm for algorithm 'HS512' HOT 4
- Duouniversal popup automatic login HOT 1
- ClientBuilder should not require redirectUri HOT 3
- Move license to LICENSE.txt in root directory HOT 1
- Client does not follow Microsoft's guideance for HttpClient class
- IUserTwoFactorTokenProvider HOT 5
- Why Doesn't the Client.cs have a method to get the access token? HOT 6
- Add support for additional User Agent customization HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from duo_universal_csharp.