-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Describe the bug
At instanciation time, caracara.client.Client configures itself, sends numerous logs and then fires a POST to https://api.eu-1.crowdstrike.com/oauth2/token to get an API token. Could it be possible to have lazy authentication ? That would mean preparing offline settings, and only trigger network requests when an API operation is required.
The falconpy behavior is not to request a token unless it's needed ( https://github.com/CrowdStrike/falconpy/blob/main/src/falconpy/api_complete.py#L307 ) ; but I might have read this wrong.
To Reproduce
Instanciate a caracara.client.Client class, there's a network call.
Expected behavior
No network call unless asked to touch the network
Environment
Operating System Version
Debian bookworm
Python Version
3.10.5
Poetry Version
1.4.1
Python Package Versions
$ pip freeze | grep -E '(caracara|falconpy)'
caracara==0.2.2
crowdstrike-falconpy==1.2.12
Additional context
We have scripts that prepare handlers to request data from various locations, and one of the providers is Caracara. For cases where all the details are already cached offline ( so far it's about session data ) ; we end up instanciating a Client object just in case ; then not using it since all the data we need is in our cache ; and instead of having instantaneous results we have to wait for one (1) HTTP call, cause by the understandable need of caracara.client.Client to request a token when instanciated.
Could it be possible to only call self.api_authentication.token() when needed, even if that means remaining unaware of the base_url variable for a while ? (which is fine, because you won't ever need it unless authenticated to answer a query ).
Feel free to say this problem is convoluted :D
Cheers,