Skip to content

Commit

Permalink
Update for new client
Browse files Browse the repository at this point in the history
  • Loading branch information
tribble committed Aug 12, 2024
1 parent fbe32ce commit 738f955
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions python-flask-sso-example/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
app.secret_key = os.getenv("APP_SECRET_KEY")

# WorkOS Setup

workos.api_key = os.getenv("WORKOS_API_KEY")
workos.client_id = os.getenv("WORKOS_CLIENT_ID")
workos.base_api_url = "http://localhost:7000/" if DEBUG else workos.base_api_url
base_api_url = "http://localhost:7000/" if DEBUG else None
workos_client = workos.WorkOSClient(
api_key=os.getenv("WORKOS_API_KEY"),
client_id=os.getenv("WORKOS_CLIENT_ID"),
base_url=base_api_url,
)

# Enter Organization ID here

Expand Down Expand Up @@ -53,11 +55,11 @@ def auth():
redirect_uri = url_for("auth_callback", _external=True)

authorization_url = (
workos.client.sso.get_authorization_url(
workos_client.sso.get_authorization_url(
redirect_uri=redirect_uri, organization_id=CUSTOMER_ORGANIZATION_ID
)
if login_type == "saml"
else workos.client.sso.get_authorization_url(
else workos_client.sso.get_authorization_url(
redirect_uri=redirect_uri, provider=login_type
)
)
Expand All @@ -72,7 +74,7 @@ def auth_callback():
# Why do I always get an error that the target does not belong to the target organization?
if code is None:
return redirect("/")
profile = workos.client.sso.get_profile_and_token(code).profile
profile = workos_client.sso.get_profile_and_token(code).profile
session["first_name"] = profile.first_name
session["raw_profile"] = profile.dict()
session["session_id"] = profile.id
Expand Down

0 comments on commit 738f955

Please sign in to comment.