-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secret token for login and certificate verification #7
Conversation
Added support for logging in with a secret token
…d required values separately
@@ -17,6 +17,9 @@ class AsyncApi: | |||
host (str): The XUI host URL. | |||
username (str): The XUI username. | |||
password (str): The XUI password. | |||
token (str | None): The XUI secret token. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for Api, more details about parameters and their usage.
@@ -75,14 +93,22 @@ def session(self, value: str) -> None: | |||
self.database.session = value | |||
|
|||
@classmethod | |||
def from_env(cls, logger: Any | None = None) -> AsyncApi: | |||
def from_env( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we store those parameters in envvars?
It would be nice if we still have an option to create an instance for API object without any additional arguments.
By, the way, since those two are optional (in some cases) we can also have both options: pass as arguments OR read from env. So if they're not passed let's try to find them in envvars.
Same for sync Api.
py3xui/utils/env.py
Outdated
postprocess_fn: Callable[[str], Any], | ||
) -> Any: | ||
keys: list[str], postprocess_fn: Callable[[str], Any], required: bool = True | ||
) -> Optional[Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any | None recommended
) # type: ignore[return-value] | ||
|
||
|
||
def xui_token() -> str | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add the required
argument to all env functions?
E.g. user specifically wants to raise an error when the parameters are not found? And for required parameters set default to True, for optional to False.
Maybe we should rename the required
argument to something more specific? E.g. raise_if_not_found
?
Continuing work on PR: #6
@snoups