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,33 +23,39 @@ An example Flask application demonstrating how to use the [WorkOS Python SDK](ht
21
23
```
22
24
23
25
2. Navigate to the sso app within the cloned repo.
26
+
24
27
```bash
25
28
$ cd python-flask-example-applications/python-flask-sso-example
26
29
```
27
30
28
31
3. Create and source a Python virtual environment. You should then see `(env)` at the beginning of your command-line prompt.
32
+
29
33
```bash
30
34
$ python3 -m venv env
31
35
$ source env/bin/activate
32
36
(env) $
33
37
```
34
38
35
39
4. Install the cloned app's dependencies.
40
+
36
41
```bash
37
42
(env) $ pip install -r requirements.txt
38
43
```
39
44
40
45
5. Obtain and make note of the following values. In the next step, these will be set as environment variables.
46
+
41
47
- Your [WorkOS API key](https://dashboard.workos.com/api-keys)
42
48
- Your [SSO-specific, WorkOS Client ID](https://dashboard.workos.com/configuration)
43
49
44
50
6. Ensure you're in the root directory for the example app, `python-flask-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.)
51
+
45
52
```bash
46
53
(env) $ touch .env
47
54
(env) $ nano .env
48
55
```
49
56
50
57
7. Once the Nano text editor opens, you can directly edit the `.env` file by listing the environment variables:
58
+
51
59
```bash
52
60
WORKOS_API_KEY=<value found in step 6>
53
61
WORKOS_CLIENT_ID=<value found in step 6>
@@ -57,43 +65,46 @@ An example Flask application demonstrating how to use the [WorkOS Python SDK](ht
57
65
To exit the Nano text editor, type `CTRL + x`. When prompted to "Save modified buffer", type `Y`, then press the `Enter` or `Return` key.
58
66
59
67
8. Source the environment variables so they are accessible to the operating system.
68
+
60
69
```bash
61
70
(env) $ source .env
62
71
```
63
72
64
73
You can ensure the environment variables were set correctly by running the following commands. The output should match the corresponding values.
74
+
65
75
```bash
66
76
(env) $ echo$WORKOS_API_KEY
67
77
(env) $ echo$WORKOS_CLIENT_ID
68
78
```
69
79
70
-
9. In `python-flask-sso-example/app.py` change the `CUSTOMER_CONNECTION_ID` string value to the connection you will be testing the login for. This can be found in your WorkOS Dashboard.
80
+
9. In `python-flask-sso-example/app.py` change the `CUSTOMER_ORGANIZATION_ID` string value to the organization you will be testing the login for. This can be found in your WorkOS Dashboard.
71
81
72
82
10. The final setup step is to start the server.
73
-
```bash
74
-
(env) $ flask run
75
-
```
76
83
77
-
If you are using macOS Monterey, port 5000 is not available and you'll need to start the app on a different port with this slightly different command.
78
-
```bash
79
-
(env) $ flask run -p 5001
80
-
```
84
+
```bash
85
+
(env) $ flask run
86
+
```
81
87
82
-
You'll know the server is running when you see no errors in the CLI, and output similar to the following is displayed:
88
+
If you are using macOS Monterey, port 5000 is not available and you'll need to start the app on a different port with this slightly different command.
83
89
84
-
```bash
85
-
* Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.
86
-
* Environment: production
87
-
WARNING: This is a development server. Do not use it in a production deployment.
88
-
Use a production WSGI server instead.
89
-
* Debug mode: off
90
-
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
91
-
```
90
+
```bash
91
+
(env) $ flask run -p 5001
92
+
```
93
+
94
+
You'll know the server is running when you see no errors in the CLI, and output similar to the following is displayed:
92
95
93
-
Navigate to `localhost:5000`, or `localhost:5001` depending on which port you launched the server, in your web browser. You should see a "Login" button. If you click this link, you'll be redirected to an HTTP `404` page because we haven't set up SSO yet!
96
+
```bash
97
+
* Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.
98
+
* Environment: production
99
+
WARNING: This is a development server. Do not use it in a production deployment.
100
+
Use a production WSGI server instead.
101
+
* Debug mode: off
102
+
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
103
+
```
94
104
95
-
You can stop the local Flask server for now by entering `CTRL + c` on the command line.
105
+
Navigate to `localhost:5000`, or `localhost:5001` depending on which port you launched the server, in your web browser. You should see a "Login" button. If you click this link, you'll be redirected to an HTTP `404` page because we haven't set up SSO yet!
96
106
107
+
You can stop the local Flask server for now by entering `CTRL + c` on the command line.
97
108
98
109
## SSO Setup with WorkOS
99
110
@@ -107,15 +118,15 @@ If you get stuck, please reach out to us at [email protected] so we can help.
107
118
108
119
11. Naviagte to the `python-flask-sso-example` directory. Source the virtual environment we created earlier, if it isn't still activated from the steps above. Start the Flask server locally.
109
120
110
-
```bash
111
-
$ cd~/Desktop/python-flask-sso-example/
112
-
$ source env/bin/activate
113
-
(env) $ flask run
114
-
```
121
+
```bash
122
+
$ cd~/Desktop/python-flask-sso-example/
123
+
$ source env/bin/activate
124
+
(env) $ flask run
125
+
```
115
126
116
-
Once running, navigate to `localhost:5000`, or `localhost:5001` depending on which port you launched the server, to test out the SSO workflow.
127
+
Once running, navigate to `localhost:5000`, or `localhost:5001` depending on which port you launched the server, to test out the SSO workflow.
0 commit comments