Open veenstrajelmer opened 1 month ago
Thanks for your proposal. We are evaluating it.
Is it already being evalutated? I now test this by requesting "dummy" dataset, and then catch the Exception for a nonexistent dataset, I get a HTTPError when the authentication fails. The exception used to be a RuntimeError, so from 0.7.0 to 0.7.2 my code broke. I would really just like to have a method in cdsapi that checks whether the authentication is valid and returns a boolean (or an error)
Is your feature request related to a problem? Please describe.
When running
c = cdsapi.Client()
it checks whether there is a CDS apikey in theCDSAPI_KEY
environment variable or in the~/.cdsapirc
file. This is useful. However, it does not check whether this key works. When you want to check if a user is indeed authorized (the apikey is correct) and properly catch it if it is not the case (but pass if authentication succeeds), one would have to do something like this:Describe the solution you'd like
It would already be helpful if not all cdsapi errors would be
RuntimeError
s. A specific cdsapiAuthenticationFailedError
would be useful. What would be even better is if there would be a function available that checks the authentication. Something like this:This function then fails if the apikey is incorrect (or authentication fails for another reason). Could this be added?
Describe alternatives you've considered
The cumbersome workaround above.
Additional context
If there is no
~/.cdsapirc
file yet, we getException("Missing/incomplete configuration file")
. It would be convenient if this genericException
is replaced with a standardFileNotFoundError
so this specific error can be catched more easily.Organisation
Deltares