Conversation
8127534 to
ea1ad2e
Compare
ff4c74a to
79fbbd9
Compare
79fbbd9 to
d500f71
Compare
|
|
||
| def _authenticate_client_credentials(self): | ||
| async def _authenticate_client_credentials(self): | ||
| assert self._client_id and self._client_secret, ( |
There was a problem hiding this comment.
i think we can remove assert from here and replace it with a check
| tenant=tenant, | ||
| scope=scope, | ||
| ) | ||
| except ValueError as e: |
There was a problem hiding this comment.
should we raise an AuthenticationError instead of logging and letting the error pass?
| @@ -0,0 +1,4 @@ | |||
| class AuthenticationError(Exception): | |||
There was a problem hiding this comment.
should we name it UiPathAuthenticationError for consistency with the runtime erros?
| if exp is not None and float(exp) > time.time(): | ||
| return token_data | ||
|
|
||
| if not token_data.refresh_token: |
There was a problem hiding this comment.
nitpick: we could move this check to the beginning of the method to have an early exit mechanism, since if token_data doesn't have a refresh_token, then we don't need to parse it and get its exp time.
|
|
||
| return TokenData.model_validate(response.json()) | ||
|
|
||
| async def ensure_valid_token(self, token_data: TokenData) -> TokenData: |
There was a problem hiding this comment.
nitpick: since this method actually returns the a TokenData object, I think naming it ensure_valid_token might be a bit misleading.
maybe get_valid_token, validate_and_refresh_token or something like this would better communicate what this method does.
| raw = json.load(f) | ||
| return AuthConfig(client_id=raw["client_id"], scope=raw["scope"]) | ||
|
|
||
| def get_authorization_url(self, redirect_uri: str) -> AuthorizationRequest: |
There was a problem hiding this comment.
nitpick: we could name this method get_authorization_request since it returns more than just the url
| if version is None: | ||
| return "auth_config_cloud.json" | ||
|
|
||
| if version.startswith("25.10"): |
There was a problem hiding this comment.
since we return "auth_config_cloud.json" for any other version besides "25.10", we could simplify this by removing:
if version is None:
return "auth_config_cloud.json"
| return redirect_uri, port | ||
|
|
||
|
|
||
| def update_env_file(env_contents: dict[str, Any]) -> None: |
There was a problem hiding this comment.
this method has a duplicate in packages\uipath\src\uipath\_utils\_auth.py
| from ._models import AccessTokenData | ||
|
|
||
|
|
||
| def parse_access_token(access_token: str) -> AccessTokenData: |
There was a problem hiding this comment.
this method has a duplicate in packages\uipath\src\uipath\_utils\_auth.py
Summary
Move auth service from
uipathtouipath-platformas a standalone service.Changes
AuthServicein platform — OAuth2 PKCE flow, token refresh, tenant discoveryStudioWebService(more methods will be added in a future PR, overwrites resolution, resources creation, project locking etc.)update_env_file,_find_free_port,http-server) inuipathlibAuthHandlerAuthServiceToDo:
Development Packages
uipath
uipath-platform