-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
proposal: x/oauth2: Add RFC 6749 error fields to RetrieveError #58125
Comments
Should be |
@icholy thanks, amended. |
CC @golang/security |
@ianlancetaylor is there anything I can do to speed up review? I see that there's a backlog of 300+ incoming proposals |
The first step here will be to get a comment from someone on @golang/security such as @rolandshoemaker . |
Unmarshalling the body ourselves, assuming it is standardized, which it looks like it is, seems like a reasonable convenience improvement. The One question is what to do if the body cannot be unmarshalled, but in that case it is probably reasonable to just spit out the raw body and move on. |
This proposal has been added to the active column of the proposals project |
We can't call the field |
@rsc the RFC calls it an "error code" https://datatracker.ietf.org/doc/html/rfc6749#section-5.2
|
ErrorCode it is. Thanks. |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Parse error response described in https://datatracker.ietf.org/doc/html/rfc6749#section-5.2 Handle unorthodox servers responding 200 in error case. Implements API changes in accepted proposal golang/go#58125 Fixes #441 Fixes #274 Updates #173 Change-Id: If9399c3f952ac0501edbeefeb3a71ed057ca8d37 GitHub-Last-Rev: 0030e27 GitHub-Pull-Request: #610 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/451076 Run-TryBot: Matt Hickford <[email protected]> Run-TryBot: Damien Neil <[email protected]> Reviewed-by: Matt Hickford <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Cody Oss <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
The issue this fork was meant to address (golang/oauth2#441) has been fixed upstream: - [proposed fix that was part of fork](golang/oauth2#442) - [upstream fix](golang/oauth2@cfe200d) (golang/go#58125) Notably, both implementations change the error returned to render more verbose details on `.Error()` if the response is a status 200 _but_ an error (see above issues) A diff against upstream indicates that there are no other changes: sourcegraph/oauth2#3 ## Test plan Test suites pass
The issue this fork was meant to address (golang/oauth2#441) has been fixed upstream: - [proposed fix that was part of fork](golang/oauth2#442) - [upstream fix](golang/oauth2@cfe200d) (golang/go#58125) Notably, both implementations change the error returned to render more verbose details on `.Error()` if the response is a status 200 _but_ an error (see above issues) A diff against upstream indicates that there are no other changes: sourcegraph/oauth2#3 ## Test plan Test suites pass
Motivation: make it easier for apps to show readable errors to users
OAuth spec RFC 6749 defines JSON error responses with three parameters:
error
,error_description
anderror_uri
. https://datatracker.ietf.org/doc/html/rfc6749#section-5.2However error type oauth2.RetrieveError merely holds the raw response body unparsed.
For clients to more easily handle errors and show users readable error messages, it would greatly help to parse JSON error responses and populate corresponding fields:
The ErrorCode field is so named to avoid conflict with the Error() method.
Would it be acceptable to change the string returned by the Error() method to be more user friendly when these fields are set?
Here's a change including parsing logic golang/oauth2#610
The text was updated successfully, but these errors were encountered: