-
Notifications
You must be signed in to change notification settings - Fork 991
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
Try to check for error
responses even when the status code isn't HTTP 400
#274
Comments
I have managed to reproduce this issue with an invalid (non-existing) clientid and clientsecret. |
Have you reported the issue to GitHub? |
No I haven't, where can I do that? |
Reported it, thanks! |
I managed to get back a fair answer to my request, which I actually totally agree with:
|
The Token contains the Raw JSON properties of the response body, which would mean you could pull out the error: tkn, err := src.Token()
if err != nil {
if tkn != nil && tkn.AccessToken == "" {
// Broken Github error response
reqError, ok := tkn.Raw["error"].(string)
if ok {
handle reqError ...
}
}
} Is that an acceptable solution? |
That is absolutely fine, thank you! |
According to https://tools.ietf.org/html/rfc6749#section-5.2 an
error
response is returned mostly when the HTTP status code is 400, but in some cases for example in GitHub anerror
response can be raised even when the status code is 200. In this caseinternal.RetrieveToken()
parses the output but with missing parameters, and continues, but the token struct is half-baked.The text was updated successfully, but these errors were encountered: