File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ class AuthModel(BaseModel):
1313
1414 url : str
1515 auth : Tuple [str , SecretStr ]
16+ access_token : Optional [str ] = None
1617 verify : Union [bool , str ] = True
1718 cert : Optional [str ] = None
1819 api_version : int = 1
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ def __init__(self, artifactory: AuthModel) -> None:
1818 self ._artifactory .auth [0 ],
1919 self ._artifactory .auth [1 ].get_secret_value (),
2020 )
21+ self ._access_token = self ._artifactory .access_token
2122 self ._api_version = self ._artifactory .api_version
2223 self ._verify = self ._artifactory .verify
2324 self ._cert = self ._artifactory .cert
@@ -78,10 +79,19 @@ def _generic_http_method_request(
7879 :return: An HTTP response
7980 """
8081
82+ if self ._access_token is not None :
83+ headers = kwargs .get ("headers" , {})
84+ headers ["Authorization" ] = f"Bearer { self ._access_token } "
85+ kwargs ["headers" ] = headers
86+
87+ auth = None
88+ else :
89+ auth = self ._auth
90+
8191 http_method = getattr (self .session , method )
8292 response : Response = http_method (
8393 f"{ self ._artifactory .url } /{ route } " ,
84- auth = self . _auth ,
94+ auth = auth ,
8595 ** kwargs ,
8696 verify = self ._verify ,
8797 cert = self ._cert ,
You can’t perform that action at this time.
0 commit comments