You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -21,35 +23,40 @@ An example Django application demonstrating how to use the [WorkOS Python SDK](h
21
23
```
22
24
23
25
2. Navigate to the Admin Portal example app within the cloned repo.
26
+
24
27
```bash
25
28
$ cd python-django-example-applications/python-django-sso-example
26
-
````
27
-
29
+
```
28
30
29
31
3. Create and source a Python virtual environment. You should then see `(env)` at the beginning of your command-line prompt.
32
+
30
33
```bash
31
34
$ python3 -m venv env
32
35
$ source env/bin/activate
33
36
(env) $
34
37
```
35
38
36
39
4. Install the cloned app's dependencies. If the `pip` command doesn't work, try `pip3` instead.
40
+
37
41
```bash
38
42
(env) $ pip install -r requirements.txt
39
43
```
40
44
41
45
5. Obtain and make note of the following values. In the next step, these will be set as environment variables.
46
+
42
47
- Your [WorkOS API key](https://dashboard.workos.com/api-keys)
43
48
- Your [SSO-specific, WorkOS Client ID](https://dashboard.workos.com/sso/configuration)
44
49
- The redirect URI. For this example, we'll use http://localhost:8000/auth/callback
45
50
46
51
6. Ensure you're in the root directory for the example app, `python-django-sso-example/`. Create a `.env` file to securely store the environment variables. Open this file with the Nano text editor. (This file is listed in this repo's `.gitignore` file, so your sensitive information will not be checked into version control.)
52
+
47
53
```bash
48
54
(env) $ touch .env
49
55
(env) $ nano .env
50
56
```
51
57
52
58
7. Once the Nano text editor opens, you can directly edit the `.env` file by listing the environment variables:
59
+
53
60
```bash
54
61
export WORKOS_API_KEY=<value found in step 6>
55
62
export WORKOS_CLIENT_ID=<value found in step 6>
@@ -59,23 +66,27 @@ An example Django application demonstrating how to use the [WorkOS Python SDK](h
59
66
To exit the Nano text editor, type `CTRL + x`. When prompted to "Save modified buffer", type `Y`, then press the `Enter` or `Return` key.
60
67
61
68
8. Source the environment variables so they are accessible to the operating system.
69
+
62
70
```bash
63
71
(env) $ source .env
64
72
```
65
73
66
74
You can ensure the environment variables were set correctly by running the following commands. The output should match the corresponding values.
75
+
67
76
```bash
68
77
(env) $ echo$WORKOS_API_KEY
69
78
(env) $ echo$WORKOS_CLIENT_ID
70
79
(env) $ echo$REDIRECT_URI
71
80
```
72
81
73
82
9. Run the Django migrations. Again, ensure you're in the `python-django-sso-example/` directory where the `manange.py` file is.
83
+
74
84
```bash
75
85
(env) $ python3 manage.py migrate
76
86
```
77
87
78
88
You should see output like:
89
+
79
90
```bash
80
91
Operations to perform:
81
92
Apply all migrations: admin, auth, contenttypes, sessions
@@ -85,30 +96,30 @@ An example Django application demonstrating how to use the [WorkOS Python SDK](h
85
96
...
86
97
```
87
98
88
-
10. 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.
99
+
10. In `python-django-sso-example/sso/views.py` change the `ORGANIZATION_ID` string value to the organization ID that you are targeting. This can be found in the WorkOS Dashboard under the Organization Settings.
89
100
90
101
11. The final setup step is to start the server.
91
-
```bash
92
-
(env) $ python3 manage.py runserver --insecure
93
-
```
94
102
95
-
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:
103
+
```bash
104
+
(env) $ python3 manage.py runserver --insecure
105
+
```
96
106
97
-
```bash
98
-
Watching for file changes with StatReloader
99
-
Performing system checks...
100
-
101
-
System check identified no issues (0 silenced).
102
-
March 18, 2021 - 04:54:50
103
-
Django version 3.1.7, using settings 'workos_django.settings'
104
-
Starting development server at http://127.0.0.1:8000/
105
-
Quit the server with CONTROL-C.
106
-
```
107
+
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:
108
+
109
+
```bash
110
+
Watching for file changes with StatReloader
111
+
Performing system checks...
107
112
108
-
Navigate to `localhost:8000` in your web browser. You should see a "Login" link. If you click this link, you'll be redirected to an HTTP `404` page because we haven't set up SSO yet!
113
+
System check identified no issues (0 silenced).
114
+
March 18, 2021 - 04:54:50
115
+
Django version 3.1.7, using settings 'workos_django.settings'
116
+
Starting development server at http://127.0.0.1:8000/
117
+
Quit the server with CONTROL-C.
118
+
```
109
119
110
-
You can stop the local Django server for now by entering `CTRL + c` on the command line.
120
+
Navigate to `localhost:8000` in your web browser. You should see a "Login" link. If you click this link, you'll be redirected to an HTTP `404` page because we haven't set up SSO yet!
111
121
122
+
You can stop the local Django server for now by entering `CTRL + c` on the command line.
112
123
113
124
## SSO Setup with WorkOS
114
125
@@ -122,15 +133,15 @@ If you get stuck, please reach out to us at [email protected] so we can help.
122
133
123
134
12. 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.
124
135
125
-
```bash
126
-
$ cd~/Desktop/python-django-sso-example/
127
-
$ source env/bin/activate
128
-
(env) $ python3 manage.py runserver
129
-
```
136
+
```bash
137
+
$ cd~/Desktop/python-django-sso-example/
138
+
$ source env/bin/activate
139
+
(env) $ python3 manage.py runserver
140
+
```
130
141
131
-
Once running, navigate to http://localhost:8000 to test out the SSO workflow.
142
+
Once running, navigate to http://localhost:8000 to test out the SSO workflow.
0 commit comments