Skip to content

Commit 618f434

Browse files
edis-uipathclaude
andcommitted
fix: replace deleted PortalService with IdentityService for OAuth token refresh
PortalService was removed from uipath._cli._auth in uipath 2.10.x. Use IdentityService + OidcUtils instead, matching the new AuthSession pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 208851d commit 618f434

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/uipath_mcp/_cli/_runtime/_token_refresh.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from enum import Enum
66

77
import httpx
8-
from uipath._cli._auth._portal_service import PortalService
8+
from uipath._cli._auth._oidc_utils import OidcUtils
99
from uipath._cli._auth._url_utils import build_service_url, resolve_domain
1010
from uipath._cli._auth._utils import get_auth_data, update_auth_file
1111
from uipath._utils._auth import parse_access_token
@@ -14,6 +14,7 @@
1414
from uipath.platform import UiPath
1515
from uipath.platform.common import TokenData
1616
from uipath.platform.common._config import UiPathApiConfig
17+
from uipath.platform.identity import IdentityService
1718

1819
logger = logging.getLogger(__name__)
1920

@@ -172,12 +173,14 @@ async def _refresh_oauth(self) -> TokenData:
172173
if not refresh_token:
173174
raise ValueError("No refresh_token found in .uipath/.auth.json")
174175

175-
def _do_refresh() -> TokenData:
176-
with PortalService(domain=self._domain) as portal:
177-
return portal.refresh_access_token(refresh_token)
176+
auth_config = await OidcUtils.get_auth_config(self._domain)
177+
client_id = auth_config["client_id"]
178178

179-
# run in a thread to avoid blocking
180-
token_data = await asyncio.to_thread(_do_refresh)
179+
identity_service = IdentityService(self._domain)
180+
token_data = await identity_service.refresh_access_token_async(
181+
refresh_token=refresh_token,
182+
client_id=client_id,
183+
)
181184

182185
try:
183186
update_auth_file(token_data)

0 commit comments

Comments
 (0)