Skip to content

Commit 6632d96

Browse files
flaviojdzgemini-code-assist[bot]drstrangelooker
authored
fix(tool/looker-conversational-analytics): OAuth token in GDA payload fix (#3058)
When using per-user OAuth (`use_client_oauth: true`), the `ask_data_insights` tool fails to authenticate with the Gemini Data Analytics API, while `get_models` and `get_explores` work correctly with the same token. The MCP server extracts the full `Authorization` header value (e.g., `"Bearer abc123"`) and passes it as `accessToken` to each tool's `Invoke()` method. The `get_models`/`get_explores` tools pass this to `GetLookerSDK()`, which sets it as an HTTP `Authorization` header where the `"Bearer "` prefix is expected. However, `ask_data_insights` was embedding the full `"Bearer abc123"` string into the JSON payload's `access_token` field sent to the GDA API, which expects only the raw token value. The fix calls `accessToken.ParseBearerToken()` to strip the `"Bearer "` prefix before placing the token into the `TokenBased` struct. This only affects the OAuth code path; the `SecretBased` (client_id/client_secret) path is unchanged. ### Before ```go oauth_creds.Token = TokenBased{AccessToken: string(accessToken)} // Produces: {"access_token": "Bearer abc123"} -- rejected by GDA API ``` ### After ```go rawToken, err := accessToken.ParseBearerToken() oauth_creds.Token = TokenBased{AccessToken: rawToken} // Produces: {"access_token": "abc123"} -- correct ``` ### Files Changed - `internal/tools/looker/lookerconversationalanalytics/lookerconversationalanalytics.go` ## PR Checklist - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md) - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/mcp-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [x] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #3057 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Mike DeAngelo <drstrangelove@google.com>
1 parent f9e3e55 commit 6632d96

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/tools/looker/lookerconversationalanalytics/lookerconversationalanalytics.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,11 @@ func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, para
249249
}
250250
oauth_creds := OAuthCredentials{}
251251
if source.UseClientAuthorization() {
252-
oauth_creds.Token = TokenBased{AccessToken: string(accessToken)}
252+
rawToken, err := accessToken.ParseBearerToken()
253+
if err != nil {
254+
return nil, err.(util.ToolboxError)
255+
}
256+
oauth_creds.Token = TokenBased{AccessToken: rawToken}
253257
} else {
254258
oauth_creds.Secret = SecretBased{ClientId: source.LookerApiSettings().ClientId, ClientSecret: source.LookerApiSettings().ClientSecret}
255259
}

0 commit comments

Comments
 (0)