10
10
app .secret_key = os .getenv ("APP_SECRET_KEY" )
11
11
12
12
# WorkOS Setup
13
-
14
- workos .api_key = os .getenv ("WORKOS_API_KEY" )
15
- workos .client_id = os .getenv ("WORKOS_CLIENT_ID" )
16
- workos .base_api_url = "http://localhost:7000/" if DEBUG else workos .base_api_url
13
+ base_api_url = "http://localhost:7000/" if DEBUG else None
14
+ workos_client = workos .WorkOSClient (
15
+ api_key = os .getenv ("WORKOS_API_KEY" ),
16
+ client_id = os .getenv ("WORKOS_CLIENT_ID" ),
17
+ base_url = base_api_url ,
18
+ )
17
19
18
20
# Enter Organization ID here
19
21
@@ -53,11 +55,11 @@ def auth():
53
55
redirect_uri = url_for ("auth_callback" , _external = True )
54
56
55
57
authorization_url = (
56
- workos . client .sso .get_authorization_url (
58
+ workos_client .sso .get_authorization_url (
57
59
redirect_uri = redirect_uri , organization_id = CUSTOMER_ORGANIZATION_ID
58
60
)
59
61
if login_type == "saml"
60
- else workos . client .sso .get_authorization_url (
62
+ else workos_client .sso .get_authorization_url (
61
63
redirect_uri = redirect_uri , provider = login_type
62
64
)
63
65
)
@@ -72,7 +74,7 @@ def auth_callback():
72
74
# Why do I always get an error that the target does not belong to the target organization?
73
75
if code is None :
74
76
return redirect ("/" )
75
- profile = workos . client .sso .get_profile_and_token (code ).profile
77
+ profile = workos_client .sso .get_profile_and_token (code ).profile
76
78
session ["first_name" ] = profile .first_name
77
79
session ["raw_profile" ] = profile .dict ()
78
80
session ["session_id" ] = profile .id
0 commit comments