databricks-sdk-go
databricks-sdk-go copied to clipboard
[ISSUE] JWT has expired
databricks clusters list -p profile_edap_dev_dbx Error: unexpected error handling request: json: cannot unmarshal number into Go struct field APIErrorBody.error_code of type string. This is likely a bug in the Databricks SDK for Go or the underlying REST API. Please report this issue with the following debugging information to the SDK issue tracker at https://github.com/databricks/databricks-sdk-go/issues. Request log:
GET /api/2.0/clusters/list
> * Host:
> * Accept: application/json
> * Authorization: REDACTED
> * User-Agent: cli/0.215.0 databricks-sdk-go/0.34.0 go/1.21.7 os/windows cmd/clusters_list sdk-feature/pagination auth/pat
< HTTP/2.0 403 Forbidden
< * Access-Control-Allow-Headers: Authorization, X-Databricks-Azure-Workspace-Resource-Id, X-Databricks-Org-Id, Content-Type
< * Access-Control-Allow-Origin: *
< * Cache-Control: no-cache, no-store, must-revalidate
< * Content-Length: 46
< * Content-Type: application/json; charset=utf-8
< * Date: Tue, 08 Oct 2024 23:52:15 GMT
< * Expires: 0
< * Pragma: no-cache
< * Server: databricks
< * Vary: Accept-Encoding
< * X-Databricks-Reason-Phrase: JWT has expired
< * X-Request-Id: c238b27d-2dcb-4bd4-a2e1-b81a194c7838
< {
< "error_code": 403,
< "message": "JWT has expired"
< }
While this is technically still an issue with databricks-sdk-go (since it seems to choke on these errors), I hit this today and was able to resolve it by refreshing my az login (since my team uses Azure CLI auth to auth with our Databricks instances). It looks like the issue here is Azure-related, so maybe worth a try.
I am hitting this when having M2mCredentials credentials explicitly set after some unknown period of time that my application runs.
w, err := databricks.NewWorkspaceClient(&databricks.Config{
Host: host,
ClientID: client_id,
ClientSecret: client_secret, // TODO: read from env var
Credentials: config.M2mCredentials{},
})
Do I need to do something to refresh the token because I can't find anything in the docs or code where I have access to do so. This is on azure if that matters but I wouldn't think it does since this is access only though the API and only using the client id/secret.