Skip to content

Commit d255628

Browse files
author
Nils Hillmann
committed
instead of ctx.error use ctx.json so that clients
parse error and error_description correctly
1 parent a4dd8fc commit d255628

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

routers/user/oauth.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ const (
108108

109109
// BearerTokenError represents an error response specified in RFC 6750
110110
type BearerTokenError struct {
111-
ErrorCode BearerTokenErrorCode
112-
ErrorDescription string
111+
ErrorCode BearerTokenErrorCode `json:"error" form:"error"`
112+
ErrorDescription string `json:"error_description"`
113113
}
114114

115115
// TokenType specifies the kind of token
@@ -635,12 +635,12 @@ func handleAuthorizeError(ctx *context.Context, authErr AuthorizeError, redirect
635635
func handleBearerTokenError(ctx *context.Context, beErr BearerTokenError) {
636636
ctx.Resp.Header().Set("WWW-Authenticate", fmt.Sprintf("Bearer realm=\"\", error=\"%s\", error_description=\"%s\"", beErr.ErrorCode, beErr.ErrorDescription))
637637
if beErr.ErrorCode == BearerTokenErrorCodeInvalidRequest {
638-
ctx.Error(http.StatusBadRequest)
638+
ctx.JSON(http.StatusBadRequest, beErr)
639639
}
640640
if beErr.ErrorCode == BearerTokenErrorCodeInvalidToken {
641-
ctx.Error(http.StatusUnauthorized)
641+
ctx.JSON(http.StatusUnauthorized, beErr)
642642
}
643643
if beErr.ErrorCode == BearerTokenErrorCodeInsufficientScope {
644-
ctx.Error(http.StatusForbidden)
644+
ctx.JSON(http.StatusForbidden, beErr)
645645
}
646646
}

0 commit comments

Comments
 (0)