If your SaaS product is built with Python’s Flask web framework and you want to incorporate Directory Sync functionality, you can do a dry-run of the Directory Sync integration on our example Flask app which makes use of the WorkOS Python SDK.
If you get stuck while following the steps below and aren't able to resolve the issue by reading our API reference or Directory Sync Setup Guide, reach out to us at [email protected] so we can help.
1. In your CLI, navigate to the directory into which you want to clone this git repo.
2. Clone this git repo using your preferred secure method (HTTPS or SSH).
3. Navigate to the cloned repo.
4. Create and source a Python virtual environment. You should then see (env) at the beginning of your command-line prompt.
5. Install the cloned app's dependencies.
6. Obtain and make note of the following values. In the next step, these will be set as environment variables.
7. Ensure you're in the root directory for the example app, python-flask-directory-sync-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.)
8. Once the Nano text editor opens, you can directly edit the .env file by listing the environment variables:
To exit the Nano text editor, type CTRL + x. When prompted to "Save modified buffer", type Y, then press the Enter or Return key.
9. Source the environment variables so they are accessible to the operating system.
You can ensure the environment variables were set correctly by running the following commands. The output should match the corresponding values.
10. Use this command to run the app:
11. Once the server is running, navigate to http://localhost:5000/users and http://localhost:5000/groups to try out Directory Sync!
When you clone this repo, the DEBUG setting is False by default in app.py. You can set DEBUG = True if you need to troubleshoot something during the tutorial, but you must use DEBUG = False in order to successfully connect to the WorkOS API.
If you get stuck and aren't able to resolve the issue by reading our API reference or tutorials, please reach out to us at [email protected] and we'll help you out.