handle edge case

This commit is contained in:
Miles Yucht 2024-09-12 10:51:36 +02:00
parent f9675ab8ea
commit 517e1b3310
No known key found for this signature in database
GPG Key ID: CDA4D62DC9997360
1 changed files with 7 additions and 3 deletions

View File

@ -49,6 +49,7 @@ var ( // Databricks SDK API: `databricks OAuth is not` will be checked for prese
ErrOAuthNotSupported = errors.New("databricks OAuth is not supported for this host") ErrOAuthNotSupported = errors.New("databricks OAuth is not supported for this host")
ErrNotConfigured = errors.New("databricks OAuth is not configured for this host") ErrNotConfigured = errors.New("databricks OAuth is not configured for this host")
ErrFetchCredentials = errors.New("cannot fetch credentials") ErrFetchCredentials = errors.New("cannot fetch credentials")
ErrDeviceCodeNotSupported = errors.New("device code flow is not supported for this host")
) )
type PersistentAuth struct { type PersistentAuth struct {
@ -129,6 +130,9 @@ func (a *PersistentAuth) DeviceCode(ctx context.Context) error {
if err != nil { if err != nil {
return err return err
} }
if cfg.Endpoint.DeviceAuthURL == "" {
return ErrDeviceCodeNotSupported
}
ctx = a.http.InContextForOAuth2(ctx) ctx = a.http.InContextForOAuth2(ctx)
deviceAuthResp, err := cfg.DeviceAuth(ctx) deviceAuthResp, err := cfg.DeviceAuth(ctx)
if err != nil { if err != nil {