Repository navigation
SDK-2869: Python - Support fetching session PDF in IDV - python - #471
mehmet-yoti merged 4 commits into
Conversation
🤖 Claude Code ReviewCode Review FindingsCriticalNone Major1.
Suggested fix: payload = (
json.dumps(pdf_request, cls=YotiEncoder).encode("utf-8")
if pdf_request is not None
else b"{}"
)2. Builder The three builder methods declare The example app ( Suggested fix: add a type guard in each setter: def with_include_images(self, include_images=True):
if not isinstance(include_images, bool):
raise TypeError("include_images must be a bool")
self.__include_images = include_images
return selfMinor3. This is fine as written (the dict keys are the JSON field names, not the attribute names), but inside No change required right now, but worth noting for any future subclassing. 4. No test asserts the actual serialised payload sent when
Suggested addition: capture the Nit5. Filename in "Content-Disposition": "attachment; filename=session-overview-{}.pdf".format(session_id)
import re
safe_id = re.sub(r'[^A-Za-z0-9_-]', '_', session_id)
"Content-Disposition": "attachment; filename=session-overview-{}.pdf".format(safe_id)6. Example
|
There was a problem hiding this comment.
🟡 Changes recommended
The request’s default Accept header excludes PDF responses and can cause HTTP 406; it must allow both PDF and JSON, with a client-test assertion verifying the built header.
1 open issue
8 files not reviewed
yoti_python_sdk/protobuf/attrpubapi_v1/AttributeChange_pb2.py: Generated fileyoti_python_sdk/protobuf/attrpubapi_v1/AttributeDisplayRequest_pb2.py: Generated fileyoti_python_sdk/protobuf/attrpubapi_v1/AttributeDisplayResponse_pb2.py: Generated fileyoti_python_sdk/protobuf/attrpubapi_v1/Attribute_pb2.py: Generated fileyoti_python_sdk/protobuf/attrpubapi_v1/DeleteSuperseded_pb2.py: Generated fileyoti_python_sdk/protobuf/attrpubapi_v1/Delete_pb2.py: Generated fileyoti_python_sdk/protobuf/attrpubapi_v1/List_pb2.py: Generated fileyoti_python_sdk/protobuf/attrpubapi_v1/Refresh_pb2.py: Generated file
What changed in this PR
Adds session overview PDF downloads to the Python SDK’s Identity Verification client, with optional content controls and a Flask example.
Changes:
- Adds the PDF endpoint, client method, and public request model/builder, preserving unset flags.
- Adds download links and tests for PDF responses, errors, and request serialization.
- Applies unrelated formatting-only changes across existing SDK code, tests, examples, and generated protobuf files.
| File | Description |
|---|---|
yoti_python_sdk/tests/test_activity_details.py |
Formatting only. |
yoti_python_sdk/tests/doc_scan/test_doc_scan_client.py |
Tests PDF responses, errors, and nested request options. |
yoti_python_sdk/tests/doc_scan/session/create/test_session_overview_pdf_request.py |
Tests PDF flags, builder behavior, and serialization. |
yoti_python_sdk/tests/doc_scan/session/create/subcheck/test_issuing_authority_sub_check.py |
Formatting only. |
yoti_python_sdk/tests/doc_scan/session/create/check/test_wathclist_check.py |
Formatting only. |
yoti_python_sdk/tests/doc_scan/session/create/check/test_liveness_check.py |
Whitespace cleanup only. |
yoti_python_sdk/tests/doc_scan/mocks.py |
Adds successful and failed PDF response fixtures. |
yoti_python_sdk/protobuf/sharepubapi_v1/ThirdPartyAttribute_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/SharingNotificationPush_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/Sharing_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/SessionData_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/ScanYotiCompleteShare_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/ReceiptPush_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/Policy_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/Location_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/IssuingAttributes_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/IdentityProfileShare_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/ExtraData_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/DataEntry_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/CancelSharing_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/sharepubapi_v1/AgeVerificationSecret_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/protobuf.py |
Formatting only. |
yoti_python_sdk/protobuf/devicepubapi_v1/StaticCredentialAuth_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/YotiYUV_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/SignedTimestamp_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/Signature_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/RsaAuthDigest_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/OptionalTypes_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/MRZ_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/Metadata_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/IdentityProfileReport_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/IdentityProfilePreview_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/IdentityProfile_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/Hmac_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/EncryptedData_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/DocumentTypes_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/DocumentFields_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/DataPrivacy_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/ChipInfo_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/AttributeMigration_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/AttributeLink_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/AdminReasonCode_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/compubapi_v1/Address_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/attrpubapi_v1/Unlock_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/attrpubapi_v1/Signing_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/attrpubapi_v1/Refresh_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/attrpubapi_v1/List_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/attrpubapi_v1/DeleteSuperseded_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/attrpubapi_v1/Delete_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/attrpubapi_v1/AttributeDisplayResponse_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/attrpubapi_v1/AttributeDisplayRequest_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/attrpubapi_v1/AttributeChange_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/protobuf/attrpubapi_v1/Attribute_pb2.py |
Generated-code formatting only. |
yoti_python_sdk/doc_scan/session/retrieve/static_liveness_resource_response.py |
Formatting only. |
yoti_python_sdk/doc_scan/session/retrieve/share_code_resource_response.py |
Formatting only. |
yoti_python_sdk/doc_scan/session/retrieve/resource_response.py |
Formatting only. |
yoti_python_sdk/doc_scan/session/retrieve/resource_container.py |
Formatting only. |
yoti_python_sdk/doc_scan/session/retrieve/image_response.py |
Formatting only. |
yoti_python_sdk/doc_scan/session/create/subcheck/issuing_authority_sub_check.py |
Formatting only. |
yoti_python_sdk/doc_scan/session/create/session_overview_pdf_request.py |
Adds optional PDF content flags and a fluent builder. |
yoti_python_sdk/doc_scan/session/create/sdk_config.py |
Formatting only. |
yoti_python_sdk/doc_scan/session/create/notification_config.py |
Formatting only. |
yoti_python_sdk/doc_scan/session/create/filter/orthogonal_restrictions_filter.py |
Formatting only. |
yoti_python_sdk/doc_scan/session/create/check/watchlist_screen.py |
Formatting only. |
yoti_python_sdk/doc_scan/session/create/check/__init__.py |
Whitespace cleanup only. |
yoti_python_sdk/doc_scan/endpoint.py |
Adds the session PDF endpoint path. |
yoti_python_sdk/doc_scan/client.py |
Adds signed PDF creation requests returning raw bytes. |
yoti_python_sdk/doc_scan/__init__.py |
Exports the PDF request model and builder. |
yoti_python_sdk/date_parser.py |
Whitespace cleanup only. |
yoti_python_sdk/activity_details.py |
Formatting only. |
setup.py |
Whitespace cleanup; dependencies unchanged. |
README.md |
Formats the existing authentication example. |
examples/yoti_example_django/yoti_example/urls.py |
Whitespace cleanup only. |
examples/doc_scan/templates/success.html |
Adds default and all-options PDF download links. |
examples/doc_scan/app.py |
Adds the PDF download route with optional query flags. |
Review effort: Balanced
| .build() | ||
| ) |
nikhilPank
left a comment
There was a problem hiding this comment.
See comment here: https://github.com/getyoti/yoti-python-sdk/pull/471/changes#r4550692863
Also, there are lots of unnecessary formatting changes in this PR, maybe they can be removed
| request = ( | ||
| SignedRequest.builder() | ||
| .with_post() | ||
| .with_pem_file(self.__key) |
There was a problem hiding this comment.
This won't work with the new central auth added in #467
you should replace .with_pem_file(self.__key) with .with_auth_strategy(self.__auth_strategy) to match that PR.
Also you need to replace .with_param("sdkId", self.__sdk_id) with self.__with_sdk_id_param(builder)
make sure #467 is merged first as well
- Add jti (UUID v4) claim to the client assertion JWT, with an optional with_jwt_id_supplier() builder override (parity with PHP/Java) - Add a configurable timeout to the auth token request (default 30s) - Don't append a trailing '?' to URLs when there are no query params - Abstract AuthStrategy methods raise NotImplementedError - Fix 'compatibility' typo and update DocScanClient docstring
Session overview PDF endpoint (POST /sessions/{id}/pdf) with optional
include_* flags nested under an "options" envelope. Rebased onto the
central auth changes (SDK-2773) and stripped of unrelated formatting-only
changes.
… PDF - Use with_auth_strategy() and __with_sdk_id_param() so the PDF request works with both signed requests and central auth tokens (SDK-2773) - Send Accept: application/pdf, application/json on the PDF request - Add tests asserting the exact wire body, headers and auth per mode
fcde199 to
a0a84b6
Compare
|
nikhilPank
left a comment
There was a problem hiding this comment.
LGTM - issues resolved
…ort-fetching-session-pdf-in-idv SDK-2869: Python - Support fetching session PDF in IDV - python
* SDK-2488: Python - Support dark mode in IDV SDK - python (#466) * Add dark_mode and primary_colour_dark_mode to SdkConfig (SDK-2488) Extends SdkConfig and SdkConfigBuilder with two new optional fields: - dark_mode (with_dark_mode, with_dark_mode_on/off/auto convenience methods) - primary_colour_dark_mode (with_primary_colour_dark_mode) Both fields are omitted from the JSON payload when not set (None). * feat(SDK-2488): Python - Support dark mode in IDV SDK [python] * SDK-2751: Add to Python SDK IDV Create Session (#470) * SDK-2530-python-create-helper-methods-for-the-idv-sdk (#468) * SDK-2773-python-support-central-auth-tokens (#467) * SDK-2773-python-support-central-auth-tokens * fix(SDK-2773): add jti claim to auth JWT and address review comments - Add jti (UUID v4) claim to the client assertion JWT, with an optional with_jwt_id_supplier() builder override (parity with PHP/Java) - Add a configurable timeout to the auth token request (default 30s) - Don't append a trailing '?' to URLs when there are no query params - Abstract AuthStrategy methods raise NotImplementedError - Fix 'compatibility' typo and update DocScanClient docstring * Merge pull request #471 from getyoti/websdk-auto/SDK-2869-python-support-fetching-session-pdf-in-idv SDK-2869: Python - Support fetching session PDF in IDV - python * Sdk 2802 python remove the api for aml check in connect (#469) * SDK-2802-python-remove-the-api-for-aml-check-in-connect * ci: pin runners to ubuntu-24.04 so Python 3.9 is still available ubuntu-latest moved to Ubuntu 26.04, which has no Python 3.9 build in actions/python-versions. The SDK still supports 3.9 (python_requires>=3.9). * feat(SDK-2827): Python - Support company_profile for IDV [python] (#472) * Bump version to 2.15.0




Summary
Adds support for fetching a session overview PDF from the IDV (Identity Verification) service. A new
create_session_overview_pdf(session_id, pdf_request=None)method is added toDocScanClientthat POSTs to/idverify/v1/sessions/{sessionId}/pdf, expects HTTP 201, and returns the raw PDF bytes. Optional boolean flags controlling PDF content (images, extracted text, device tracking) are cleanly omitted from the request JSON when not set.Changes
yoti_python_sdk/doc_scan/client.py— Addedcreate_session_overview_pdf(session_id, pdf_request=None)method toDocScanClient; raisesDocScanExceptionon non-201 response.yoti_python_sdk/doc_scan/endpoint.py— Addedcreate_session_overview_pdf_path(session_id)static helper to build the/idverify/v1/sessions/{sessionId}/pdfendpoint path.yoti_python_sdk/doc_scan/session/create/session_overview_pdf_request.py— New file introducingSessionOverviewPdfRequest(serialisable dataclass) andSessionOverviewPdfRequestBuilderwith three optional boolean flags:include_images,include_extracted_text,include_device_tracking. Unset flags are omitted from JSON entirely viaremove_null_values.yoti_python_sdk/doc_scan/__init__.py— ExportsSessionOverviewPdfRequestandSessionOverviewPdfRequestBuilderfrom theyoti_python_sdk.doc_scanpublic API.examples/doc_scan/app.py— Added/session-pdfFlask route that reads optional query-string flags, builds aSessionOverviewPdfRequest, callscreate_session_overview_pdf, and streams the PDF back asapplication/pdf.examples/doc_scan/templates/success.html— Added two download links on the success page: one for a plain PDF and one with all optional flags enabled.yoti_python_sdk/tests/doc_scan/test_doc_scan_client.py— 3 new client tests covering: successful PDF generation with no request body, successful PDF generation with a populated request, and error handling on non-201 responses.yoti_python_sdk/tests/doc_scan/session/create/test_session_overview_pdf_request.py— 12 new tests forSessionOverviewPdfRequestandSessionOverviewPdfRequestBuildercovering default/None serialisation, individual flag combinations, and chained builder usage.QA Test Steps
Setup
websdk-auto/SDK-2869-python-support-fetching-session-pdf-in-idv.pip install -e ".[dev]".pytest yoti_python_sdk/tests/doc_scan/ -v— all 27 tests should pass (15 client tests, 12 request-model tests).Happy path — SDK method
4. Instantiate
DocScanClientwith valid sandbox credentials.5. Create a session and call
doc_scan_client.create_session_overview_pdf(session_id)with no extra arguments.6. Verify the return value is
bytesand starts with%PDF.7. Call again with a
SessionOverviewPdfRequestBuilder().with_include_images().with_include_extracted_text().build()and verify the same.Happy path — Flask example app
8. Configure the example app with valid
YOTI_CLIENT_SDK_IDand key, then runflask runfromexamples/doc_scan/.9. Complete a Doc Scan session. On the success page, click "Download Session PDF" — a PDF should download.
10. Click "Download Session PDF (with images & text)" — the PDF should download and include images/extracted text.
11. Navigate directly to
/session-pdf?include_images=true&include_extracted_text=true&include_device_tracking=truewith a valid session cookie.Edge cases
12. Call
create_session_overview_pdfwith an invalid/expiredsession_id— verify aDocScanExceptionis raised with an informative message.13. Construct
SessionOverviewPdfRequest()with no arguments and verifyto_json()returns{}(all flags omitted).14. Set only
include_images=Falseexplicitly and verify only that key appears in the serialised JSON (not the other two).Regression
15. Run the full test suite (
pytest) — no pre-existing tests should be broken.Notes
None(not set), rather than being sent asfalse. This matches the backend contract and avoids unintended overrides.bytes; callers are responsible for writing to file or streaming./session-pdfroute readssession_idfrom the Flask session cookie set during the normal flow; it will return a 400 error if no session has been created yet.Related Jira: SDK-2869
Auto-generated by Claude dynamic workflow