Creating a user consent application using the Python SDK
Project structure
First, we'll set up the project directory:
- Navigate to the directory in which you'd like to store your project.
- Create a folder called
sinch-user-consent
and navigate into it. - Create a file called
app.py
.
Setting up your environment
Now, we'll install the prerequisites for your application.
Creating a Python virtual environment
Open a terminal or command prompt and navigate into the project folder you created. Here, you will create a virtual environment calledvenv
. You don't need to do this, but it is recommended. Python virtual environments function as sandboxes, allowing you to install application specific packages without installing them globally.In Windows and Mac you can create a virtual environment with the command
python -m venv venv
In Linux you can create a virtual environment with the command
virtualenv --python python venv
Now you need to activate the virtual environment.
In Windows, run the command:
venv\Scripts\activate
In Linux, the command is:
source venv/bin/activate
Now that your virtual environment is activated, you can install the dependencies your application needs to function.
Installing Flask
This is a Flask application so you need to install Flask. You can do this with pip.
pip install flask
Installing the SDK
To effectively leverage Sinch SMS capability with Python, you need to install the SDK. You can do this with pip.
pip install sinch
Installing ngrok
If you successfully completed the Receive an SMS Message guide, you'll have used ngrok to set up a tunnel to your local server. Install ngrok with the command:
npm install ngrok -g
If you haven't already, set up a free account with ngrok. Now we've installed everything we need, we can start creating the application.
Collecting information to initialize the client
On the next page, you'll need to intialize the SDK.
Before initializing a client using this SDK, you'll need three pieces of information:
- Your Project ID
- An access key ID
- An access key Secret