From 517e1b3310e6536bb305291837dad7c48f2f884d Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 12 Sep 2024 10:51:36 +0200 Subject: [PATCH] handle edge case --- libs/auth/oauth.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/auth/oauth.go b/libs/auth/oauth.go index e6b9e241..0c250d8c 100644 --- a/libs/auth/oauth.go +++ b/libs/auth/oauth.go @@ -46,9 +46,10 @@ const ( ) var ( // Databricks SDK API: `databricks OAuth is not` will be checked for presence - ErrOAuthNotSupported = errors.New("databricks OAuth is not supported for this host") - ErrNotConfigured = errors.New("databricks OAuth is not configured for this host") - ErrFetchCredentials = errors.New("cannot fetch credentials") + ErrOAuthNotSupported = errors.New("databricks OAuth is not supported for this host") + ErrNotConfigured = errors.New("databricks OAuth is not configured for this host") + ErrFetchCredentials = errors.New("cannot fetch credentials") + ErrDeviceCodeNotSupported = errors.New("device code flow is not supported for this host") ) type PersistentAuth struct { @@ -129,6 +130,9 @@ func (a *PersistentAuth) DeviceCode(ctx context.Context) error { if err != nil { return err } + if cfg.Endpoint.DeviceAuthURL == "" { + return ErrDeviceCodeNotSupported + } ctx = a.http.InContextForOAuth2(ctx) deviceAuthResp, err := cfg.DeviceAuth(ctx) if err != nil {