Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 23, 2024
1 parent 9604b13 commit 557bd2d
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions src/ansys/hps/client/authenticate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"""Module that provides authentication for the user with a password or refresh token against the
HPS authentication service."""
import logging
from typing import Union, List
from typing import List, Union

import requests

Expand Down Expand Up @@ -158,16 +158,16 @@ def authenticate(


def authenticate_via_action_token(
auth_url: str = "https://127.0.0.1:8443/hps/auth/realms/rep",
action_token_pathprefix: str = "job-action-token",
username: str = None,
scope: List[str] = ["openid"],
client_id: str = "rep-cli",
audience: List[str] = None,
access_token: str = None,
timeout: float = 10.0,
verify: Union[bool, str] = True,
**kwargs,
auth_url: str = "https://127.0.0.1:8443/hps/auth/realms/rep",
action_token_pathprefix: str = "job-action-token",
username: str = None,
scope: List[str] = ["openid"],
client_id: str = "rep-cli",
audience: List[str] = None,
access_token: str = None,
timeout: float = 10.0,
verify: Union[bool, str] = True,
**kwargs,
):
"""
Authenticates the user by requesting an action token.
Expand Down Expand Up @@ -200,22 +200,22 @@ def authenticate_via_action_token(
JSON-encoded content of a :class:`requests.Response` object.
"""

action_token_resp = request_action_token(auth_url,
action_token_pathprefix,
username,
scope,
client_id,
access_token,
audience,
timeout=timeout,
verify=verify,
**kwargs)
action_token_resp = request_action_token(
auth_url,
action_token_pathprefix,
username,
scope,
client_id,
access_token,
audience,
timeout=timeout,
verify=verify,
**kwargs,
)

auth_api = action_token_resp["link"]

log.debug(
f"Action token received {action_token_resp['token']}."
)
log.debug(f"Action token received {action_token_resp['token']}.")

with requests.Session() as session:
session.verify = verify
Expand All @@ -235,16 +235,16 @@ def authenticate_via_action_token(


def request_action_token(
auth_url: str = "https://127.0.0.1:8443/hps/auth/realms/rep",
action_token_pathprefix: str = "job-action-token",
username: str = None,
scope: List[str] = ["openid"] ,
client_id: str = "job-api-call",
access_token: str = None,
audience: List[str] = None,
timeout: float = 10.0,
verify: Union[bool, str] = True,
**kwargs,
auth_url: str = "https://127.0.0.1:8443/hps/auth/realms/rep",
action_token_pathprefix: str = "job-action-token",
username: str = None,
scope: List[str] = ["openid"],
client_id: str = "job-api-call",
access_token: str = None,
audience: List[str] = None,
timeout: float = 10.0,
verify: Union[bool, str] = True,
**kwargs,
):
"""
Request an action token for a user fully authenticated.
Expand Down Expand Up @@ -314,4 +314,4 @@ def request_action_token(
resp = session.post(action_token_url, json=data, timeout=timeout)

raise_for_status(resp)
return resp.json()
return resp.json()

0 comments on commit 557bd2d

Please sign in to comment.