databricks-sdk-go icon indicating copy to clipboard operation
databricks-sdk-go copied to clipboard

Token missing scope when calling `CredentialsAPI.List` api from SDK

Open karanpopat opened this issue 2 years ago • 2 comments

Description

Getting error Error: Your token is missing the required scopes for this endpoint when calling function func (*provisioning.CredentialsAPI).GetByCredentialsId in the SDK.

While this call using the same token works using CLI

➜  ~ databricks account credentials list    
abca1fb8-0fba-46fa-e3es-6db449b12345  databricks-workspace-stack-ea6c4-credentials  arn:aws:iam::123456789012:role/databricks-workspace-stack-ea6c4-role

Reproduction

client, err := databricks.NewAccountClient()
if err != nil {
	fmt.Println("Unable to initialize client:", err)
	return nil, err
}
name := "abcd"
credential, err := client.Credentials.GetByCredentialsName(context.Background(), name)

Expected behavior The API call from SDK should return similar data as we get from the CLI without failing due to the token scope.

Debug Logs

2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: hydrateWithIgnoreError returned error Your token is missing the required scopes for this endpoint
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: shouldRetryError err: Your token is missing the required scopes for this endpoint, retryConfig:
2023-07-07 16:09:02.920 UTC [WARN]  steampipe-plugin-databricks.plugin: [WARN]  168874614199: doList callHydrateWithRetries (databricks-168874614199) returned err Your token is missing the required scopes for this endpoint
2023-07-07 16:09:02.920 UTC [WARN]  steampipe-plugin-databricks.plugin: [WARN]  168874614199: QueryData StreamError Your token is missing the required scopes for this endpoint (databricks-168874614199)
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: QueryData.fetchComplete
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: executeListCall COMPLETE (databricks-168874614199)
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: rowData chan returned nil - wait for rows to complete (databricks-168874614199)
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: buildRowsAsync goroutine returning (databricks-168874614199)
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: streamRows error chan select: Your token is missing the required scopes for this endpoint
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: aborting cache set operation
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: QueryData streamRows DONE (databricks-168874614199)
2023-07-07 16:09:02.920 UTC [WARN]  steampipe-plugin-databricks.plugin: [WARN]  168874614199: streamRows for databricks-168874614199 - execution has failed (Your token is missing the required scopes for this endpoint) - calling queryCache.AbortSet
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: End execute span
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: executeForConnection DEFER (databricks-168874614199)
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: Execute complete callId: databricks-168874614199 table: databricks_account_credential
2023-07-07 16:09:02.920 UTC [WARN]  steampipe-plugin-databricks.plugin: [WARN]  168874614199: executeForConnection databricks returned error Your token is missing the required scopes for this endpoint
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: executeForConnection databricks returned
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: output wg complete - send nil row (168874614199)
2023-07-07 16:09:02.920 UTC [WARN]  steampipe-plugin-databricks.plugin: [WARN]  168874614199: error channel received Your token is missing the required scopes for this endpoint
2023-07-07 16:09:02.920 UTC [TRACE] steampipe-plugin-databricks.plugin: [TRACE] 168874614199: empty row on output channel - we are done
2023-07-07 16:09:02.920 UTC [INFO]  steampipe-plugin-databricks.plugin: [INFO]  168874614199: Plugin execute complete (168874614199)

karanpopat avatar Jul 07 '23 16:07 karanpopat

The CLI uses this SDK, so there is some way to get it to work. How are you authenticating to Databricks?

mgyucht avatar Oct 25 '23 21:10 mgyucht

Hi there, could you please provide an update? Otherwise, I will close this issue out in a week.

mgyucht avatar Nov 30 '23 15:11 mgyucht