Skip to content
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

[bot] add new function set_token #314

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions gazu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,18 @@ def get_event_host(client=raw.default_client):

def set_event_host(url, client=raw.default_client):
raw.set_event_host(url, client=client)


def set_token(token, client=raw.default_client):
"""
Store authentication token to reuse them for all requests.

Args:
new_tokens (dict): Tokens to use for authentication.
"""
tokens = {}
if isinstance(token, dict):
tokens["access_token"] = token["access_token"]
else:
tokens["access_token"] = token
return raw.set_tokens(tokens, client=client)
7 changes: 7 additions & 0 deletions gazu/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ def new_person(
desktop_login="",
departments=[],
password=None,
is_bot=False,
expiration_date=None,
client=default,
):
"""
Expand All @@ -196,6 +198,9 @@ def new_person(
and studio manager)
desktop_login (str): The login the users uses to log on its computer.
departments (list): The departments for the person.
password (str): The password for the person.
is_bot (bool): Whether the person is a bot or not.
expiration_date (str): The expiration date for the person.
Returns:
dict: Created person.
"""
Expand All @@ -212,6 +217,8 @@ def new_person(
"desktop_login": desktop_login,
"departments": normalize_list_of_models_for_links(departments),
"password": password,
"is_bot": is_bot,
"expiration_date": expiration_date,
},
client=client,
)
Expand Down
Loading