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

@ -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 {