Skip to content

Commit fcb7a12

Browse files
authored
CLOUDP-279932: trim suffix when provided base url contains / (#458)
1 parent 84f7346 commit fcb7a12

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

auth/credentials/api.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package credentials
22

33
import (
44
"context"
5-
"go.mongodb.org/atlas-sdk/v20240805005/internal/core"
65
"net/http"
6+
"strings"
7+
8+
"go.mongodb.org/atlas-sdk/v20240805005/internal/core"
79
)
810

911
// tokenAPIPath for obtaining OAuth Access Token from server
@@ -34,7 +36,8 @@ type AtlasTokenSourceOptions struct {
3436
func NewTokenSourceWithOptions(opts AtlasTokenSourceOptions) TokenSource {
3537
var tokenURL string
3638
if opts.BaseURL != nil {
37-
tokenURL = *opts.BaseURL + tokenAPIPath
39+
baseUrlNoSuffix := strings.TrimSuffix(*opts.BaseURL, "/")
40+
tokenURL = baseUrlNoSuffix + tokenAPIPath
3841
} else {
3942
tokenURL = serverURL
4043
}

auth/credentials/transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (t *OAuthCustomHTTPTransport) RoundTrip(req *http.Request) (*http.Response,
2424
}
2525

2626
// Inject the Token into the request
27-
t.setAuthHeader(req, token);
27+
t.setAuthHeader(req, token)
2828

2929
// Proceed with the underlying transport
3030
return t.UnderlyingTransport.RoundTrip(req)

0 commit comments

Comments
 (0)