File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,13 @@ def test_get_profile_and_token_returns_expected_workosprofile_object(
214214 assert profile_and_token .access_token == "01DY34ACQTM3B1CSX1YSZ8Z00D"
215215 assert profile_and_token .profile .to_dict () == mock_profile
216216
217+ def test_get_profile (self , setup_with_client_id , mock_profile , mock_request_method ):
218+ mock_request_method ("get" , mock_profile , 200 )
219+
220+ profile = self .sso .get_profile (123 )
221+
222+ assert profile .to_dict () == mock_profile
223+
217224 def test_get_connection (
218225 self , setup_with_client_id , mock_connection , mock_request_method
219226 ):
Original file line number Diff line number Diff line change 55
66import workos
77from workos .exceptions import ConfigurationException
8- from workos .resources .sso import WorkOSProfileAndToken
8+ from workos .resources .sso import WorkOSProfile , WorkOSProfileAndToken
99from workos .utils .connection_types import ConnectionType
1010from workos .utils .request import (
1111 RequestHelper ,
1818
1919AUTHORIZATION_PATH = "sso/authorize"
2020TOKEN_PATH = "sso/token"
21+ PROFILE_PATH = "sso/profile"
2122
2223OAUTH_GRANT_TYPE = "authorization_code"
2324
@@ -86,6 +87,25 @@ def get_authorization_url(
8687
8788 return prepared_request .url
8889
90+ def get_profile (self , accessToken ):
91+ """
92+ Verify that SSO has been completed successfully and retrieve the identity of the user.
93+
94+ Args:
95+ accessToken (str): the token used to authenticate the API call
96+
97+ Returns:
98+ WorkOSProfile
99+ """
100+
101+ token = accessToken
102+
103+ response = self .request_helper .request (
104+ PROFILE_PATH , method = REQUEST_METHOD_GET , token = token
105+ )
106+
107+ return WorkOSProfile .construct_from_response (response )
108+
89109 def get_profile_and_token (self , code ):
90110 """Get the profile of an authenticated User
91111
You can’t perform that action at this time.
0 commit comments