1313# limitations under the License.
1414import json
1515from abc import ABC , abstractmethod
16- from typing import Optional , Tuple
16+ from typing import Optional
1717
1818import requests
1919from requests .auth import AuthBase , HTTPBasicAuth
@@ -33,7 +33,7 @@ class Authorization(ABC):
3333 """
3434
3535 @abstractmethod
36- def create_auth (self , headers ) -> Tuple [Optional [AuthBase ], dict ]:
36+ def create_auth (self , headers ) -> tuple [Optional [AuthBase ], dict ]:
3737 """
3838 Prepares authentication components for an HTTP request.
3939
@@ -89,7 +89,7 @@ class OAuth(Authorization):
8989 def __init__ (self , asset , soar_client ):
9090 self .asset = asset
9191 self .soar = soar_client
92- self .state_key = f"oauth_token_{ asset . asset_id } "
92+ self .state_key = f"oauth_token_{ self . soar . get_asset_id () } "
9393
9494 def _generate_new_token (self ):
9595 """
@@ -114,9 +114,13 @@ def _generate_new_token(self):
114114 access_token = json .loads (response .text ).get ("access_token" )
115115
116116 except requests .exceptions .RequestException as e :
117- raise ActionFailure (f"Error fetching OAuth token from { token_url } . Details: { e } " ) from e
117+ raise ActionFailure (
118+ f"Error fetching OAuth token from { token_url } . Details: { e } "
119+ ) from e
118120 except json .JSONDecodeError as e :
119- raise ActionFailure ("Error parsing response from server while fetching token" ) from e
121+ raise ActionFailure (
122+ "Error parsing response from server while fetching token"
123+ ) from e
120124
121125 if not access_token :
122126 raise ActionFailure ("Access token not found in response body" )
0 commit comments