-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
https://tools.ietf.org/html/rfc6749 defines error responses returned to clients, however this library seems to completely shadow received responses so one can't distinguish between different type of errors.
For example for Resource Owner Password Credentials Grant (https://tools.ietf.org/html/rfc6749#section-4.3) RFC6749 defines error message and codes in https://tools.ietf.org/html/rfc6749#section-5.2 Now we can't distinguish between e.g. invalid_request and invalid_grant as what the func PasswordCredentialsToken returns is basic error message
Lines 174 to 176 in 2cd4472
| if code := r.StatusCode; code < 200 || code > 299 { | |
| return nil, fmt.Errorf("oauth2: cannot fetch token: %v\nResponse: %s", r.Status, body) | |
| } |
Well, since there is response in the error message I could parse it but I think you realize ugliness of such a hack ;)
What I would expect here is following standard concepts from golang standard library and to introduce package errors, and export them. So instead returning meaningless errors (something went wrong but what?) we could receive something more useful like ErrInvalidRequest or ErrInvalidGrant.
Right now my biggest real life issue is that I can't distinguish that user provided wrong credentials from any other unknown error.