summaryrefslogtreecommitdiffstats
path: root/app/oauth.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-08-02 11:05:36 -0400
committerChristopher Speller <crspeller@gmail.com>2017-08-02 08:05:36 -0700
commit4d452143947e285045b793654c3752027cd1af63 (patch)
tree31474611625155a961a3ae119dc70ad34dcde328 /app/oauth.go
parent2c5eefa17ac5eb8ff3b843bd9037b3122b5b3fa8 (diff)
downloadchat-4d452143947e285045b793654c3752027cd1af63.tar.gz
chat-4d452143947e285045b793654c3752027cd1af63.tar.bz2
chat-4d452143947e285045b793654c3752027cd1af63.zip
Add more debugging info to server logs for failed OAuth requests (#7039)
Diffstat (limited to 'app/oauth.go')
-rw-r--r--app/oauth.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/app/oauth.go b/app/oauth.go
index e2d389569..c93882d4d 100644
--- a/app/oauth.go
+++ b/app/oauth.go
@@ -672,23 +672,26 @@ func AuthorizeOAuthUser(w http.ResponseWriter, r *http.Request, service, code, s
req.Header.Set("Accept", "application/json")
var ar *model.AccessResponse
- var respBody []byte
+ var bodyBytes []byte
if resp, err := utils.HttpClient().Do(req); err != nil {
return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.token_failed.app_error", nil, err.Error())
} else {
+ bodyBytes, _ = ioutil.ReadAll(resp.Body)
+ resp.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))
+
ar = model.AccessResponseFromJson(resp.Body)
defer CloseBody(resp)
if ar == nil {
- return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "")
+ return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_response.app_error", nil, "response_body="+string(bodyBytes))
}
}
if strings.ToLower(ar.TokenType) != model.ACCESS_TOKEN_TYPE {
- return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_token.app_error", nil, "token_type="+ar.TokenType+", response_body="+string(respBody))
+ return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_token.app_error", nil, "token_type="+ar.TokenType+", response_body="+string(bodyBytes))
}
if len(ar.AccessToken) == 0 {
- return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.missing.app_error", nil, "")
+ return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.missing.app_error", nil, "response_body="+string(bodyBytes))
}
p = url.Values{}