unioslo / tsd-api-client

Command line client for the TSD HTTP API
BSD 3-Clause "New" or "Revised" License
13 stars 5 forks source link

Fix Click incompatibility and authorization errors #96

Closed haatveit closed 2 years ago

haatveit commented 2 years ago

The autocompletion Click parameter was renamed to shell_complete in Click 8.0, and removed in Click 8.1. Adjusted the tacl module accordingly.

Made authorization issues in the administrator lead to an HTTPError exception being raised, so that this is handled by the handle_request_errors decorator. Previously this would lead to a KeyError on trying to access the API key and a traceback being printed.

Example:

(tsdapiclient) ➜  tsd-api-client git:(get_tsd_api_key_exception) ✗ tacl --register
Choose the API environment by typing one of the following numbers:
1 - for normal production usage
2 - for use over fx03 network
3 - for testing
4 - for Educloud normal production usage
5 - for Educloud testing
 > 4
username > adjasjdja
password > 
one time code > dsfjsdjfj
ec project > sdjfjsdjf
GET: https://api.fp.educloud.no/v1/sdjfjsdjf/auth/tsd/api_key
401 Client Error: Unauthorized for url: https://api.fp.educloud.no/v1/sdjfjsdjf/auth/tsd/api_key
The request was unsuccesful. Exiting.