mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-09 15:38:08 -05:00
fix(tools/looker): Looker client OAuth nil pointer error (#2231)
The original implementation initializes auth session using direct struct creation `&rtl.AuthSession` which does not have a source field initialized, causing nil pointer error when the sdk is trying to access this source field. This is fixed by using the`NewAuthSession()` constructor which automatically initializes a source field. Fix: https://github.com/googleapis/genai-toolbox/issues/2230 --------- Co-authored-by: Dr. Strangelove <drstrangelove@google.com>
This commit is contained in:
@@ -47,6 +47,8 @@ func GetLookerSDK(useClientOAuth bool, config *rtl.ApiSettings, client *v4.Looke
|
||||
if accessToken == "" {
|
||||
return nil, fmt.Errorf("no access token supplied with request")
|
||||
}
|
||||
|
||||
session := rtl.NewAuthSession(*config)
|
||||
// Configure base transport with TLS
|
||||
transport := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
@@ -55,16 +57,15 @@ func GetLookerSDK(useClientOAuth bool, config *rtl.ApiSettings, client *v4.Looke
|
||||
}
|
||||
|
||||
// Build transport for end user token
|
||||
newTransport := &transportWithAuthHeader{
|
||||
Base: transport,
|
||||
AuthToken: accessToken,
|
||||
session.Client = http.Client{
|
||||
Transport: &transportWithAuthHeader{
|
||||
Base: transport,
|
||||
AuthToken: accessToken,
|
||||
},
|
||||
}
|
||||
|
||||
// return SDK with new Transport
|
||||
return v4.NewLookerSDK(&rtl.AuthSession{
|
||||
Config: *config,
|
||||
Client: http.Client{Transport: newTransport},
|
||||
}), nil
|
||||
return v4.NewLookerSDK(session), nil
|
||||
}
|
||||
|
||||
if client == nil {
|
||||
|
||||
Reference in New Issue
Block a user