66 CompleteConnectAccountResponse ,
77 ConnectAccountRequest ,
88 ConnectAccountResponse ,
9- ConnectParams ,
109)
1110from auth0_server_python .error import (
1211 ApiError ,
@@ -38,23 +37,16 @@ async def connect_account(
3837 if response .status_code != 201 :
3938 error_data = response .json ()
4039 raise MyAccountApiError (
41- title = error_data .get ("title" ),
42- type = error_data .get ("type" ),
43- detail = error_data .get ("detail" ),
44- status = error_data .get ("status" ),
40+ title = error_data .get ("title" , None ),
41+ type = error_data .get ("type" , None ),
42+ detail = error_data .get ("detail" , None ),
43+ status = error_data .get ("status" , None ),
4544 validation_errors = error_data .get ("validation_errors" , None )
4645 )
4746
4847 data = response .json ()
4948
50- return ConnectAccountResponse (
51- auth_session = data ["auth_session" ],
52- connect_uri = data ["connect_uri" ],
53- connect_params = ConnectParams (
54- ticket = data ["connect_params" ]["ticket" ]
55- ),
56- expires_in = data ["expires_in" ]
57- )
49+ return ConnectAccountResponse .model_validate (data )
5850
5951 except Exception as e :
6052 if isinstance (e , MyAccountApiError ):
@@ -81,22 +73,16 @@ async def complete_connect_account(
8173 if response .status_code != 201 :
8274 error_data = response .json ()
8375 raise MyAccountApiError (
84- title = error_data .get ("title" ),
85- type = error_data .get ("type" ),
86- detail = error_data .get ("detail" ),
87- status = error_data .get ("status" ),
88- validation_errors = error_data .get ("validation_errors" )
76+ title = error_data .get ("title" , None ),
77+ type = error_data .get ("type" , None ),
78+ detail = error_data .get ("detail" , None ),
79+ status = error_data .get ("status" , None ),
80+ validation_errors = error_data .get ("validation_errors" , None )
8981 )
9082
9183 data = response .json ()
9284
93- return CompleteConnectAccountResponse (
94- id = data ["id" ],
95- connection = data ["connection" ],
96- access_type = data ["access_type" ],
97- scopes = data ["scopes" ],
98- created_at = data ["created_at" ]
99- )
85+ return CompleteConnectAccountResponse .model_validate (data )
10086
10187 except Exception as e :
10288 if isinstance (e , MyAccountApiError ):
0 commit comments