diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-08-24 10:16:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-24 10:16:57 -0400 |
commit | 03fd4bc4e61db20a93685d7dc7854d45791a960c (patch) | |
tree | b738b3c3d725429985e9d264c6535b7725a83d2c /api | |
parent | 308ef8169690fd9ad947a7f1865b0f71c86df2ca (diff) | |
download | chat-03fd4bc4e61db20a93685d7dc7854d45791a960c.tar.gz chat-03fd4bc4e61db20a93685d7dc7854d45791a960c.tar.bz2 chat-03fd4bc4e61db20a93685d7dc7854d45791a960c.zip |
Temporarily add response body logging for access token request to help debugging (#3872)
Diffstat (limited to 'api')
-rw-r--r-- | api/oauth.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/api/oauth.go b/api/oauth.go index 6e7649d8d..59e68ece3 100644 --- a/api/oauth.go +++ b/api/oauth.go @@ -4,6 +4,7 @@ package api import ( + "bytes" "crypto/tls" b64 "encoding/base64" "fmt" @@ -769,10 +770,16 @@ func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser req.Header.Set("Accept", "application/json") var ar *model.AccessResponse + var respBody []byte if resp, err := client.Do(req); err != nil { return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.token_failed.app_error", nil, err.Error()) } else { - ar = model.AccessResponseFromJson(resp.Body) + // temporarily read the raw body for debugging purposes + respBody, _ = ioutil.ReadAll(resp.Body) + + reader := bytes.NewReader(respBody) + + ar = model.AccessResponseFromJson(reader) defer func() { ioutil.ReadAll(resp.Body) resp.Body.Close() @@ -783,7 +790,7 @@ func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser } 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) + return nil, "", nil, model.NewLocAppError("AuthorizeOAuthUser", "api.user.authorize_oauth_user.bad_token.app_error", nil, "token_type="+ar.TokenType+", response_body="+string(respBody)) } if len(ar.AccessToken) == 0 { |