inventree / inventree-python

Python library for communication with inventree via API
https://docs.inventree.org/en/latest/api/python/python/
MIT License
26 stars 34 forks source link

[feature] authentication check #180

Closed T0jan closed 1 year ago

T0jan commented 1 year ago

Hi again,

while working on a project using this package I discovered a shortcoming at least when using the token authentication mode but maybe the implementation for password based authentication could be improved as well. Right now there is no straight authentication check. https://github.com/inventree/inventree-python/blob/18d7dddf9dd9d773d432ae6eea7613db213f0bd0/inventree/api.py#L204

can somewhat be used as a check if the entered password and username combination is valid by monitoring the return of the function but for token authentication the function can not be used right now.

So either a new function e.g. checkAuth() could be added to give a clear entry point for other developers. testServer() also could be expanded to contain this authentication check. The third option could be to adjust requestToken() in a way that it also works with tokens as authentication. The last one feels a bit ugly as one would then request the token he already entered again but probably would be the less invasive change in the API.

opinions? If any option is preferred I could implement it then in the next days.

SchrodingersGat commented 1 year ago

I do like the idea of an atomic "checkAuth" method - if you are willing to implement this, that would be great :)

SchrodingersGat commented 1 year ago

Implemented in https://github.com/inventree/inventree-python/pull/182