Skip to content

Add a util function to check validity of API Key #100

@codingfabi

Description

@codingfabi

Hi Everyone!

I am trying to use the ORS in another python package and would like to allow the users of my package to set an API key from outside. The whole package functionality is highly dependant on the ORS client to work and therefor it would be nice to check for API key validity when creating the client object.
As far as I can see there is no util function or status inside the client object to do this. I would now have to do a test query with the client an catch 403 errors and map them to an internal exception.

Problem

Right now it is possible to do something like the following successfully:

coords = ((8.34234,48.23424),(8.34423,48.26424))

client = openrouteservice.Client(key="some_arbitrary_wrong_key")
client.directions(coords, dry_run='true')

Suggestion

I would suggest to either make the dry_run function return an exception when the api key is invalid or to add a util function to the client that allows me to do the following;

client = openrouteservice.Client(key=api_key)
client.healthCheck()

which would either throw an exception or just return an error object with a fixed internal error code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions