Skip to content

Commit 2d6c598

Browse files
author
Rohan Jadvani
authored
Update state type from dict to `string (#30)
1 parent f925e43 commit 2d6c598

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

tests/test_sso.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ def setup(self, set_api_key_and_project_id):
1515
self.provider = ConnectionType.GoogleOAuth
1616
self.customer_domain = "workos.com"
1717
self.redirect_uri = "https://localhost/auth/callback"
18-
self.state = {
19-
"things": "with_stuff",
20-
}
18+
self.state = json.dumps({"things": "with_stuff",})
2119

2220
self.sso = SSO()
2321

@@ -84,7 +82,7 @@ def test_authorization_url_has_expected_query_params_with_provider(self):
8482
"client_id": workos.project_id,
8583
"redirect_uri": self.redirect_uri,
8684
"response_type": RESPONSE_TYPE_CODE,
87-
"state": json.dumps(self.state),
85+
"state": self.state,
8886
}
8987

9088
def test_authorization_url_has_expected_query_params_with_domain(self):
@@ -101,7 +99,7 @@ def test_authorization_url_has_expected_query_params_with_domain(self):
10199
"client_id": workos.project_id,
102100
"redirect_uri": self.redirect_uri,
103101
"response_type": RESPONSE_TYPE_CODE,
104-
"state": json.dumps(self.state),
102+
"state": self.state,
105103
}
106104

107105
def test_authorization_url_has_expected_query_params_with_domain_and_provider(self):
@@ -120,7 +118,7 @@ def test_authorization_url_has_expected_query_params_with_domain_and_provider(se
120118
"client_id": workos.project_id,
121119
"redirect_uri": self.redirect_uri,
122120
"response_type": RESPONSE_TYPE_CODE,
123-
"state": json.dumps(self.state),
121+
"state": self.state,
124122
}
125123

126124
def test_get_profile_returns_expected_workosprofile_object(

workos/sso.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_authorization_url(
4242
Kwargs:
4343
domain (str) - The domain a user is associated with, as configured on WorkOS
4444
redirect_uri (str) - A valid redirect URI, as specified on WorkOS
45-
state (dict) - A dict passed to WorkOS, that'd be preserved through the authentication workflow, passed
45+
state (str) - An encoded string passed to WorkOS that'd be preserved through the authentication workflow, passed
4646
back as a query parameter
4747
provider (ConnectionType) - Authentication service provider descriptor
4848
@@ -67,7 +67,7 @@ def get_authorization_url(
6767
params["domain"] = domain
6868

6969
if state is not None:
70-
params["state"] = json.dumps(state)
70+
params["state"] = state
7171

7272
prepared_request = Request(
7373
"GET",

0 commit comments

Comments
 (0)