This project integrates Sumsub's identity verification service with a Flask application, allowing you to create applicants, add documents, and retrieve their status. It uses Google Cloud Firestore for storing verification data.
Before you begin, ensure you have the following installed:
- Python 3.12 or higher
- Flask
- Google Cloud SDK
- Sumsub API credentials (https://docs.sumsub.com/reference/about-sumsub-api)
- Access to Google Cloud Firestore
-
Clone the repository:
git clone <https://github.com/BABABUSOLA/sumsub> cd <sumsub>
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # For Unix/macOS venv\Scripts\activate # For Windows
-
Install the required packages:
pip install -r requirements.txt
-
Set up Google Cloud credentials:
Ensure you have your
GOOGLE_APPLICATION_CREDENTIALS
environment variable set to the path of your service account JSON file, the service account should be in the root folder. You can set it up as follows:export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-file.json" # For Unix/macOS set GOOGLE_APPLICATION_CREDENTIALS=C:\path\to\your\service-account-file.json # For Windows
-
Create a
.env
file in the root directory of your project to store configuration variables. An example configuration might look like this:FLASK_ENV=development SECRET_KEY=your-secret-key SUMSUB_API_URL=https://api.sumsub.com SUMSUB_API_TOKEN=your-api-token
-
Update
config.py
with your specific configuration details.
Send a POST request to /create_applicant
with the following JSON body:
{
"externalUserId": "user123",
"email": "[email protected]",
"phone": "+1234567890",
"lang": "en",
"type": "individual"
}
Send a POST request to /add_document
with form-data including:
applicant_id
: The ID of the applicantfile
: The document filemetadata
: Additional metadata
Send a GET request to /get_status/<applicant_id>
to retrieve the status of the applicant.
- PermissionDenied (403): Ensure your service account has the correct permissions for Firestore and Sumsub.
- NotFound (404): Verify that you have set up Firestore correctly and the project is correctly configured.
This error often occurs if the JSON response from an API is empty or malformed. Ensure that your API requests are properly configured and that the response is valid JSON.