Skip to content

Commit 3f13bba

Browse files
committed
fix(oauth): Output oauth request with token header when RoundTrip is called.
1 parent 3f11441 commit 3f13bba

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

auth_providers/auth_oauth.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"crypto/x509"
2020
"fmt"
21+
"log"
2122
"net/http"
2223
"os"
2324
"strings"
@@ -441,14 +442,22 @@ func (b *CommandConfigOauth) GetServerConfig() *Server {
441442

442443
// RoundTrip executes a single HTTP transaction, adding the OAuth2 token to the request
443444
func (t *oauth2Transport) RoundTrip(req *http.Request) (*http.Response, error) {
445+
log.Printf("[DEBUG] Attempting to get oAuth token from: %s %s", req.Method, req.URL)
444446
token, err := t.src.Token()
445447
if err != nil {
446448
return nil, fmt.Errorf("failed to retrieve OAuth token: %w", err)
447449
}
448450

451+
if token == nil || token.AccessToken == "" {
452+
return nil, fmt.Errorf("received empty OAuth token")
453+
}
454+
449455
// Clone the request to avoid mutating the original
456+
log.Printf("[DEBUG] Adding oAuth token to request: %s %s", req.Method, req.URL)
450457
reqCopy := req.Clone(req.Context())
451458
token.SetAuthHeader(reqCopy)
459+
requestCurlStr, _ := RequestToCurl(reqCopy)
460+
log.Printf("[DEBUG] curl command: %s", requestCurlStr)
452461

453462
return t.base.RoundTrip(reqCopy)
454463
}

0 commit comments

Comments
 (0)