Skip to content

Commit 738f955

Browse files
committed
Update for new client
1 parent fbe32ce commit 738f955

File tree

1 file changed

+9
-7
lines changed
  • python-flask-sso-example

1 file changed

+9
-7
lines changed

python-flask-sso-example/app.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
app.secret_key = os.getenv("APP_SECRET_KEY")
1111

1212
# 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+
)
1719

1820
# Enter Organization ID here
1921

@@ -53,11 +55,11 @@ def auth():
5355
redirect_uri = url_for("auth_callback", _external=True)
5456

5557
authorization_url = (
56-
workos.client.sso.get_authorization_url(
58+
workos_client.sso.get_authorization_url(
5759
redirect_uri=redirect_uri, organization_id=CUSTOMER_ORGANIZATION_ID
5860
)
5961
if login_type == "saml"
60-
else workos.client.sso.get_authorization_url(
62+
else workos_client.sso.get_authorization_url(
6163
redirect_uri=redirect_uri, provider=login_type
6264
)
6365
)
@@ -72,7 +74,7 @@ def auth_callback():
7274
# Why do I always get an error that the target does not belong to the target organization?
7375
if code is None:
7476
return redirect("/")
75-
profile = workos.client.sso.get_profile_and_token(code).profile
77+
profile = workos_client.sso.get_profile_and_token(code).profile
7678
session["first_name"] = profile.first_name
7779
session["raw_profile"] = profile.dict()
7880
session["session_id"] = profile.id

0 commit comments

Comments
 (0)