Skip to content

Commit 09adf6f

Browse files
authored
🐛 Fix: remove context deadline from oauth2 tokenSource (#110)
1 parent 5b32094 commit 09adf6f

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mullerpeter-databricks-datasource",
33
"private": true,
4-
"version": "1.3.4",
4+
"version": "1.3.5",
55
"description": "Databricks SQL Connector",
66
"scripts": {
77
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",

pkg/integrations/oauth2_client_credentials.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"golang.org/x/oauth2/clientcredentials"
99
"net/http"
1010
"sync"
11-
"time"
1211
)
1312

1413
type oauth2ClientCredentials struct {
@@ -26,6 +25,7 @@ func (c *oauth2ClientCredentials) Authenticate(r *http.Request) error {
2625
if c.tokenSource != nil {
2726
token, err := c.tokenSource.Token()
2827
if err != nil {
28+
log.DefaultLogger.Error("token fetching failed", "err", err)
2929
return err
3030
}
3131
token.SetAuthHeader(r)
@@ -39,23 +39,17 @@ func (c *oauth2ClientCredentials) Authenticate(r *http.Request) error {
3939
Scopes: c.scopes,
4040
}
4141

42-
// Create context with 1m timeout to cancel token fetching
43-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
44-
if cancel != nil {
45-
log.DefaultLogger.Debug("ignoring defer for timeout to not cancel original request")
46-
}
47-
48-
c.tokenSource = config.TokenSource(ctx)
42+
c.tokenSource = config.TokenSource(context.Background())
4943

5044
log.DefaultLogger.Debug("token fetching started")
5145
token, err := c.tokenSource.Token()
5246

5347
if err != nil {
5448
log.DefaultLogger.Error("token fetching failed", "err", err)
5549
return err
56-
} else {
57-
log.DefaultLogger.Debug("token fetched successfully")
5850
}
51+
52+
log.DefaultLogger.Debug("token fetched successfully")
5953
token.SetAuthHeader(r)
6054

6155
return nil

0 commit comments

Comments
 (0)