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
Copy file name to clipboardExpand all lines: python-flask-sso-example/README.md
+18-12Lines changed: 18 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,10 +44,10 @@ An example Flask application demonstrating how to use the [WorkOS Python SDK](ht
44
44
45
45
5. Obtain and make note of the following values. In the next step, these will be set as environment variables.
46
46
47
-
- Your [WorkOS API key](https://dashboard.workos.com/api-keys)
48
-
- Your [SSO-specific, WorkOS Client ID](https://dashboard.workos.com/configuration)
47
+
- Your [WorkOS API key and Client ID](https://dashboard.workos.com/get-started)
49
48
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.)
49
+
6. Ensure you're in the root directory for the example app, `python-flask-sso-example/`.
50
+
7. 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
51
52
52
```bash
53
53
(env) $ touch .env
@@ -57,11 +57,17 @@ An example Flask application demonstrating how to use the [WorkOS Python SDK](ht
57
57
7. Once the Nano text editor opens, you can directly edit the `.env` file by listing the environment variables:
58
58
59
59
```bash
60
-
WORKOS_API_KEY=<value found in step 6>
61
-
WORKOS_CLIENT_ID=<value found in step 6>
60
+
WORKOS_API_KEY=<value found in step 5>
61
+
WORKOS_CLIENT_ID=<value found in step 5>
62
62
APP_SECRET_KEY=<any string value you\'d like>
63
63
```
64
64
65
+
If you are unsure what to use for the `APP_SECRET_KEY`, you can generate a random UUID using Python.
To exit the Nano text editor, type`CTRL + x`. When prompted to "Save modified buffer", type`Y`, then press the `Enter` or `Return` key.
66
72
67
73
8. Source the environment variables so they are accessible to the operating system.
@@ -73,22 +79,22 @@ An example Flask application demonstrating how to use the [WorkOS Python SDK](ht
73
79
You can ensure the environment variables were set correctly by running the following commands. The output should match the corresponding values.
74
80
75
81
```bash
76
-
(env) $ echo$WORKOS_API_KEY
77
-
(env) $ echo$WORKOS_CLIENT_ID
82
+
(env) $ echo$WORKOS_API_KEY| grep sk_test_
83
+
(env) $ echo$WORKOS_CLIENT_ID| grep client_
78
84
```
79
85
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.
86
+
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 by clicking on the "Organizations" link on the left side of the dashboard.
81
87
82
88
10. The final setup step is to start the server.
83
89
84
90
```bash
85
-
(env) $ flask run
91
+
(env) $ flask run -h localhost
86
92
```
87
93
88
94
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.
89
95
90
96
```bash
91
-
(env) $ flask run -p 5001
97
+
(env) $ flask run -h localhost -p 5001
92
98
```
93
99
94
100
You'll know the server is running when you see no errors in the CLI, and output similar to the following is displayed:
@@ -102,15 +108,15 @@ Use a production WSGI server instead.
102
108
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
103
109
```
104
110
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!
111
+
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 saying "Invalid redirect URI" because we haven't set up SSO yet!
106
112
107
113
You can stop the local Flask server for now by entering `CTRL + c` on the command line.
108
114
109
115
## SSO Setup with WorkOS
110
116
111
117
Follow the [SSO authentication flow instructions](https://workos.com/docs/sso/guide/introduction) to set up an SSO connection.
112
118
113
-
When you get to the step where you provide the `REDIRECT_URI` value, use http://localhost:5000/auth/callback.
119
+
When you get to the step with the "Add Redirect URI" value, use `http://localhost:5000/auth/callback`
114
120
115
121
If you get stuck, please reach out to us at [email protected] so we can help.
0 commit comments