Skip to content

Commit d46a22c

Browse files
awolfdenAdam Wolfman
andauthored
Remove domain from SSO app (#9)
Co-authored-by: Adam Wolfman <[email protected]>
1 parent fcdd59d commit d46a22c

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

python-django-sso-example/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ An example Django application demonstrating how to use the [WorkOS Python SDK](h
9090
. . .
9191
```
9292

93-
11. In `python-django-sso-example/sso/views.py` change the `CUSTOMER_EMAIL_DOMAIN` string value to an email domain that makes sense for your testing purposes if the default `gmail.com` isn't relevant.
93+
11. In `python-django-sso-example/sso/views.py` change the `CONNECTION_ID` string value to the connection ID that you are targeting. This can be found in the WorkOS Dashboard under the Connection Settings.
9494

9595
12. The final setup step is to start the server.
9696
```bash
97-
(env) $ python3 manage.py runserver
97+
(env) $ python3 manage.py runserver --insecure
9898
```
9999

100100
You'll know the server is running when you see no warnings or errors in the CLI, and output similar to the following is displayed:
@@ -125,7 +125,7 @@ If you get stuck, please reach out to us at [email protected] so we can help.
125125
126126
## Testing the Integration
127127
128-
1. Naviagte to the `python-django-sso-example` directory, which contains the `manage.py` file. Source the virtual environment we created earlier, if it isn't still activated from the steps above. Start the Django server locally.
128+
13. Naviagte to the `python-django-sso-example` directory, which contains the `manage.py` file. Source the virtual environment we created earlier, if it isn't still activated from the steps above. Start the Django server locally.
129129

130130
```bash
131131
$ cd ~/Desktop/python-django-sso-example/

python-django-sso-example/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ requests==2.25.1
88
sqlparse==0.4.2
99
urllib3==1.26.5
1010
workos==1.2.0
11+
python-dotenv

python-django-sso-example/sso/templates/sso/login_successful.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<body class="container_success">
77
<div class="logged_in_nav">
88
<div class="flex">
9-
<img src={{image}} alt="Profile Image">
109
<p>You're logged in {{first_name}}, welcome!</p>
1110
</div>
1211
<div>

python-django-sso-example/sso/views.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# Constants
1616
# Required: Fill in either domain or customer_ID or both, at least one must be populated to generate auth connection.
1717
# For testing purposes we fitted domain with gmail.com as an example, please edit and add domains as needed for your testing.
18-
CUSTOMER_EMAIL_DOMAIN = 'gmail.com'
19-
CONNECTION_ID = ''
18+
19+
CONNECTION_ID = 'xxx'
2020
REDIRECT_URI = os.getenv('REDIRECT_URI')
2121

2222

@@ -27,10 +27,9 @@ def login(request):
2727
def auth(request):
2828

2929
authorization_url = workos.client.sso.get_authorization_url(
30-
domain = CUSTOMER_EMAIL_DOMAIN,
30+
connection= CONNECTION_ID,
3131
redirect_uri= REDIRECT_URI,
32-
state={},
33-
connection= CONNECTION_ID
32+
state={},
3433
)
3534
return redirect(authorization_url)
3635

@@ -42,16 +41,10 @@ def auth_callback(request):
4241
print(p_profile)
4342
first_name = p_profile['profile']['first_name']
4443

45-
if "picture" in p_profile['profile']['raw_attributes']:
46-
image = p_profile['profile']['raw_attributes']['picture']
47-
else:
48-
image = "../static/images/workos_logo.png"
49-
5044
raw_profile = p_profile['profile']
5145

5246
return render(request, 'sso/login_successful.html', {
5347
"p_profile": p_profile,
5448
"first_name": first_name,
55-
"image": image,
5649
"raw_profile": raw_profile
5750
})

0 commit comments

Comments
 (0)