Skip to content

Commit 2643cb0

Browse files
Add intent_options parameter on Portal.generate_link() method
1 parent 2521bcb commit 2643cb0

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from typing import Optional, Protocol
1+
from typing import Optional, Protocol, Dict, Literal, Union
22
from workos.types.portal.portal_link import PortalLink
33
from workos.types.portal.portal_link_intent import PortalLinkIntent
4+
from workos.types.portal.portal_link_intent_options import IntentOptions
45
from workos.utils.http_client import SyncHTTPClient
56
from workos.utils.request_helper import REQUEST_METHOD_POST
67

@@ -16,6 +17,7 @@ def generate_link(
1617
organization_id: str,
1718
return_url: Optional[str] = None,
1819
success_url: Optional[str] = None,
20+
intent_options: Optional[IntentOptions] = None,
1921
) -> PortalLink:
2022
"""Generate a link to grant access to an organization's Admin Portal
2123
@@ -47,13 +49,16 @@ def generate_link(
4749
organization_id: str,
4850
return_url: Optional[str] = None,
4951
success_url: Optional[str] = None,
52+
intent_options: Optional[IntentOptions] = None,
5053
) -> PortalLink:
5154
json = {
5255
"intent": intent,
5356
"organization": organization_id,
5457
"return_url": return_url,
5558
"success_url": success_url,
59+
"intent_options": intent_options,
5660
}
61+
5762
response = self._http_client.request(
5863
PORTAL_GENERATE_PATH, method=REQUEST_METHOD_POST, json=json
5964
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from typing import TypedDict
2+
3+
4+
class SsoIntentOptions(TypedDict):
5+
bookmark_slug: str
6+
7+
8+
class IntentOptions(TypedDict):
9+
sso: SsoIntentOptions

0 commit comments

Comments
 (0)