diff --git a/falcon/api_client.go b/falcon/api_client.go index d91b7105..98547d05 100644 --- a/falcon/api_client.go +++ b/falcon/api_client.go @@ -25,13 +25,16 @@ func NewClient(ac *ApiConfig) (*client.CrowdStrikeAPISpecification, error) { return nil, errors.New("Invalid Context for falcon.ApiConfig.Context. Make that ApiConfig.Context is set.") } - if ac.AccessToken == "" { - if err := ac.Cloud.Autodiscover(ac.Context, ac.ClientId, ac.ClientSecret); err != nil { - return nil, err + // If HostOverride is provided we do not need to discover the cloud + if ac.HostOverride == "" { + if ac.AccessToken == "" { + if err := ac.Cloud.Autodiscover(ac.Context, ac.ClientId, ac.ClientSecret); err != nil { + return nil, err + } + } else if ac.Cloud == CloudAutoDiscover { + // There is nothing in the access token (JWT) which identifies the cloud. + return nil, errors.New("Cannot autodiscover cloud when using an access token. Please specify the cloud explicitly.") } - } else if ac.Cloud == CloudAutoDiscover { - // There is nothing in the access token (JWT) which identifies the cloud. - return nil, errors.New("Cannot autodiscover cloud when using an access token. Please specify the cloud explicitly.") } var authenticatedClient *http.Client diff --git a/falcon/api_config.go b/falcon/api_config.go index 8190cef0..2441cdac 100644 --- a/falcon/api_config.go +++ b/falcon/api_config.go @@ -11,6 +11,7 @@ import ( // ApiConfig object is used to initialise and configure API Client. Together with NewClient function, ApiConfig provides preferred way to initiate API communication. type ApiConfig struct { // AccessToken is the access token used to access the CrowdStrike Falcon platform. + // If used either Cloud or HostOverride must be provided. // *required* if ClientId and ClientSecret are empty. AccessToken string // Client ID used for authentication with CrowdStrike Falcon platform. @@ -24,9 +25,8 @@ type ApiConfig struct { // This Context object will be used only when authenticating with the OAuth interface. Context context.Context // Cloud allows us to select Falcon Cloud to connect. - // *required* if AccessToken is used. Cloud CloudType - // HostOverride allows to override default host (default: api.crowdstrike.com) + // HostOverride allows to override host. Cloud will be ignored. HostOverride string // BasePathOverride allows to override default base path (default: /) BasePathOverride string