Skip to content

Commit d8d3023

Browse files
Add intent_options_sso_bookmark_slug parameter on Portal.generate_link() method
1 parent 2521bcb commit d8d3023

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

tests/test_portal.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,26 @@ def setup(self, sync_http_client_for_test):
1313
def mock_portal_link(self):
1414
return {"link": "https://id.workos.com/portal/launch?secret=secret"}
1515

16-
def test_generate_link_sso(self, mock_portal_link, mock_http_client_with_response):
17-
mock_http_client_with_response(self.http_client, mock_portal_link, 201)
16+
def test_generate_link_sso(
17+
self, mock_portal_link, capture_and_mock_http_client_request
18+
):
19+
request_kwargs = capture_and_mock_http_client_request(
20+
self.http_client, mock_portal_link, 201
21+
)
1822

1923
response = self.portal.generate_link(
20-
intent="sso", organization_id="org_01EHQMYV6MBK39QC5PZXHY59C3"
24+
intent="sso",
25+
organization_id="org_01EHQMYV6MBK39QC5PZXHY59C3",
26+
intent_options_sso_bookmark_slug="my_app",
2127
)
2228

29+
assert request_kwargs["url"].endswith("/portal/generate_link")
30+
assert request_kwargs["method"] == "post"
31+
assert request_kwargs["json"] == {
32+
"intent": "sso",
33+
"organization": "org_01EHQMYV6MBK39QC5PZXHY59C3",
34+
"intent_options": {"sso": {"bookmark_slug": "my_app"}},
35+
}
2336
assert response.link == "https://id.workos.com/portal/launch?secret=secret"
2437

2538
def test_generate_link_domain_verification(

workos/portal.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Protocol
1+
from typing import Optional, Protocol, Dict, Literal
22
from workos.types.portal.portal_link import PortalLink
33
from workos.types.portal.portal_link_intent import PortalLinkIntent
44
from workos.utils.http_client import SyncHTTPClient
@@ -16,6 +16,7 @@ def generate_link(
1616
organization_id: str,
1717
return_url: Optional[str] = None,
1818
success_url: Optional[str] = None,
19+
intent_options_sso_bookmark_slug: Optional[str] = None,
1920
) -> PortalLink:
2021
"""Generate a link to grant access to an organization's Admin Portal
2122
@@ -47,13 +48,22 @@ def generate_link(
4748
organization_id: str,
4849
return_url: Optional[str] = None,
4950
success_url: Optional[str] = None,
51+
intent_options_sso_bookmark_slug: Optional[str] = None,
5052
) -> PortalLink:
51-
json = {
53+
json: dict[str, str | None | dict[str, dict[str, str]]] = {
5254
"intent": intent,
5355
"organization": organization_id,
5456
"return_url": return_url,
5557
"success_url": success_url,
5658
}
59+
60+
if intent_options_sso_bookmark_slug:
61+
json["intent_options"] = {
62+
"sso": {
63+
"bookmark_slug": intent_options_sso_bookmark_slug,
64+
}
65+
}
66+
5767
response = self._http_client.request(
5868
PORTAL_GENERATE_PATH, method=REQUEST_METHOD_POST, json=json
5969
)

0 commit comments

Comments
 (0)