Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- run: pip install -U setuptools
- run: pip install -U setuptools wheel

- run: pip install -r requirements.txt
- run: pip install --no-cache-dir -r requirements.txt

- run: pip install -e .[dev]
- run: pip install --no-cache-dir -e .[dev]

- run: pytest -v

Expand All @@ -44,12 +44,12 @@ jobs:
with:
python-version: 3.9

- run: pip install --upgrade setuptools
- run: pip install --upgrade setuptools wheel

- run: pushd examples/aml && pip install -r requirements.txt && popd
- run: pushd examples/aml && pip install --no-cache-dir -r requirements.txt && popd

- run: pushd examples/yoti_example_django && pip install --upgrade pip && pip install -r requirements.txt && popd
- run: pushd examples/yoti_example_django && pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt && popd

- run: pushd examples/yoti_example_flask && pip install -r requirements.txt && popd
- run: pushd examples/yoti_example_flask && pip install --no-cache-dir -r requirements.txt && popd

- run: pushd examples/doc_scan && pip install -r requirements.txt && popd
- run: pushd examples/doc_scan && pip install --no-cache-dir -r requirements.txt && popd
3 changes: 3 additions & 0 deletions examples/digitalidentity/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Required Keys
YOTI_CLIENT_SDK_ID=yourClientSdkId
YOTI_KEY_FILE_PATH=yourKeyFilePath
11 changes: 11 additions & 0 deletions examples/digitalidentity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Yoti Share v2 Python Example

## Running the example project

1. Rename the [.env.example](.env.example) file to `.env` and fill in the required configuration values
2. Add your SDK ID to the [templates/index.html](templates/index.html) file
3. Create a virtual environment with `python3 -m venv .venv`
4. Active the environment `. .venv/bin/activate`
5. Install the dependencies with `pip install -r requirements.txt`
6. Start the server `flask run --port 8000`
7. Visit `http://127.0.0.1:8000`
Empty file.
134 changes: 134 additions & 0 deletions examples/digitalidentity/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import json, requests
from flask import Flask, Response, request, render_template


from cryptography.fernet import base64

from settings import YOTI_API_URL, YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH

from yoti_python_sdk.digital_identity import (
DigitalIdentityClient
)

app = Flask(__name__)

@app.route("/")
def index():
return render_template("index.html")

@app.route("/sessions")
def sessions():
session_config = {
"policy": {
"wanted": [
{
"name": "date_of_birth",
"derivation": "age_over:18",
"optional": "false"
}
,
{
"name": "full_name"
},
{
"name": "email_address"
},
{
"name": "phone_number"
},
{
"name": "selfie"
},
{
"name": "date_of_birth",
"derivation": "age_over:18"
},
{
"name": "nationality"
},
{
"name": "gender"
},
{
"name": "document_details"
},
{
"name": "document_images"
}],
"wanted_auth_types": [],
"wanted_remember_me": "false",
},
"extensions": [],
"subject": {
"subject_id": "some_subject_id_string"
}, # Optional reference to a user ID
"notification": {
"url": "https://webhook.site/818dc66b-e18b-4767-92c5-47c7af21629c",
"method": "POST",
"headers": {},
"verifyTls": "true"
},
"redirectUri": "/profile" # Mandatory redirect URI but not required for Non-browser flows
}

digital_identity_client = DigitalIdentityClient(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH, YOTI_API_URL)

share_session_result = digital_identity_client.create_share_session(session_config)

session_id = share_session_result.id

# create_qr_code_result = create_share_qr_code(share_session_result.id)
# get_share_session_result = get_share_session(share_session_result.id)
# get_qr_code_result = get_share_qr_code(create_qr_code_result.id)

# Return Session ID JSON
return json.dumps({"session_id": session_id})

@app.route("/create-qr-code")
def create_qr_code():
# Get query params - sessionId
session_id = request.args.get('sessionId')
digital_identity_client = DigitalIdentityClient(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH, YOTI_API_URL)

# Create QR Code
create_qr_code_result = digital_identity_client.create_share_qr_code(session_id)

# Return QR Code ID and URI JSON
return json.dumps({"qr_code_id": create_qr_code_result.id, "qr_code_uri": create_qr_code_result.uri})

@app.route("/render-qr-code")
def render_qr_code():
# Get query params - qrCodeUri
qr_code_uri = request.args.get('qrCodeUri')
# Make a POST request to the API to create a QR Code image
url = "https://api.yoti.com/api/v1/qrcodes/image"
payload = { "url": str(qr_code_uri) }
headers = {
"Accept": "image/png",
"Content-Type": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)

# Return QR Code Image as PNG
return Response(response.content, mimetype='image/png')

@app.route("/profile")
def profile():
# Get query params - receiptId
receipt_id = request.args.get('receiptId')
digital_identity_client = DigitalIdentityClient(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH, YOTI_API_URL)

share_receipt = digital_identity_client.get_share_receipt(receipt_id)
age_over_verification = share_receipt.userContent.profile.find_age_over_verification(18)
selfie = share_receipt.userContent.profile.selfie.value
attribute_list = share_receipt.userContent.profile.attributes
full_name = share_receipt.userContent.profile.full_name.value
data = base64.b64encode(selfie).decode("utf-8")
selfie_image = "data:{0};base64,{1}".format("image/jpeg", data)
age_verified = age_over_verification.result

return render_template("profile.html", age_verified=age_verified, selfie=selfie, full_name=full_name, selfie_image=selfie_image, attribute_list = attribute_list)

if __name__ == "__main__":
app.run(host="0.0.0.0", ssl_context="adhoc")
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAxtXhHY0ZxiTWSGjC8Y0EHsXpmV3FPJo6Dne1skP9e7pe2i0I
5tmvPVcQsOckrBjVP/H4G+Lzqtu7JfbD5BHZeqrec6PEITGBsrTAhcLjVQzUefN/
mFkOinlOXBuPxMP5hZttFrNjqPjRhhlYrtQV2uOh/F/UGpqupgtJPKgF6mquDEGA
lHAxCDMwwl+NtZgg1N5w7pDUJYc/cNwI8X0afTTLneCqTSD+t9dARVgcXpnJm1WK
0XyJ4u6ENgN1fUcKPC3MP2isbTZe895dAVlvUH2ADD8q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Ge12QIBjZ3IQLzRV1yO0IFO0alvI+D2F17io+REasio
pTaxAoGBANSMXb+sAnXgyu1hK/fOI5QlKNqBfK/PcwrI0nYwHzIqs5Xs5/k5NLH9
yZyIcDrrk5DJDWJ63gA0WjSL5oHzo5IOHSAkcMc/H7L/4rNFdYNmjkMaTK3Ms4In
xZcz7HaJ1Rxvh/y/lyDn27hsm30WpNfi6lcawBFHCTYdfyWIXj8P
-----END RSA PRIVATE KEY-----
3 changes: 3 additions & 0 deletions examples/digitalidentity/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flask>=3.0.1
python-dotenv>=1.0.1
yoti>=2.15
60 changes: 60 additions & 0 deletions examples/digitalidentity/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements.txt requirements.in
#
asn1==2.2.0
# via yoti
blinker==1.7.0
# via flask
certifi==2023.11.17
# via requests
cffi==1.16.0
# via cryptography
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via flask
cryptography==42.0.1
# via
# pyopenssl
# yoti
deprecated==1.2.10
# via yoti
flask==3.0.1
# via -r requirements.in
future==0.18.3
# via yoti
idna==3.6
# via requests
iso8601==0.1.13
# via yoti
itsdangerous==2.1.2
# via flask
jinja2==3.1.3
# via flask
markupsafe==2.1.4
# via
# jinja2
# werkzeug
protobuf==3.20.1
# via yoti
pycparser==2.21
# via cffi
pyopenssl==24.0.0
# via yoti
python-dotenv==1.0.1
# via -r requirements.in
pytz==2022.1
# via yoti
requests==2.31.0
# via yoti
urllib3==2.1.0
# via requests
werkzeug==3.0.1
# via flask
wrapt==1.16.0
# via deprecated
yoti==2.14.2
# via -r requirements.in
16 changes: 16 additions & 0 deletions examples/digitalidentity/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from os import environ
from os.path import dirname, join

from dotenv import load_dotenv

dotenv_path = join(dirname(__file__), ".env")
load_dotenv(dotenv_path)

YOTI_CLIENT_SDK_ID = environ.get("YOTI_CLIENT_SDK_ID", None)
YOTI_KEY_FILE_PATH = environ.get("YOTI_KEY_FILE_PATH", None)
YOTI_API_URL = environ.get("YOTI_API_URL", "https://api.yoti.com/share")

if YOTI_CLIENT_SDK_ID is None or YOTI_KEY_FILE_PATH is None:
raise ValueError("YOTI_CLIENT_SDK_ID or YOTI_KEY_FILE_PATH is None")

YOTI_APP_BASE_URL = environ.get("YOTI_APP_BASE_URL", "https://127.0.0.1:8000")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/digitalidentity/static/assets/icons/address.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions examples/digitalidentity/static/assets/icons/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/digitalidentity/static/assets/icons/document.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions examples/digitalidentity/static/assets/icons/email.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions examples/digitalidentity/static/assets/icons/gender.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/digitalidentity/static/assets/icons/nationality.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/digitalidentity/static/assets/icons/phone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/digitalidentity/static/assets/icons/profile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions examples/digitalidentity/static/assets/icons/verified.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/digitalidentity/static/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading