### Generate a Yoti Quickstart URL Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt Provides a code example for generating a URL that initiates the Yoti quickstart flow. This URL is used to redirect users to the Yoti app for authentication. ```python from yoti_sdk.client import YotiClient # Assume yoti_client is already initialized # sdk_id = "YOUR_SDK_ID" # pem_file_path = "path/to/your/yoti.pem" # yoti_client = YotiClient(sdk_id, pem_file_path) # Define the desired outcome and remember URL outcome_name = "my_app_outcome" remember_url = "https://your.callback.url/" # Define the attributes you want to request from the user # Example: "given_names", "family_name", "email_address" attributes_to_request = ["given_names", "family_name", "email_address"] quick_url = yoti_client.get_quick_receipt_url( outcome_name, remember_url, attributes_to_request ) print("Yoti Quickstart URL:", quick_url) ``` -------------------------------- ### Example: Yoti Python SDK Usage Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_missing_profile.txt Demonstrates basic usage of the Yoti Python SDK, including initialization and common operations. This snippet assumes the SDK has been installed and necessary configuration is available. ```python from yoti_sdk.client import Client # Initialize the Yoti client with your SDK ID and key file path client = Client("sdk_id", "path/to/your/key.pem") # Example of making a request (replace with actual method) # response = client.some_operation(data) # print(response) print("Yoti SDK initialized successfully.") ``` -------------------------------- ### Yoti SDK: Basic Usage Example Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response.txt A fundamental example demonstrating the basic usage of the Yoti Python SDK. This snippet typically involves setting up the client, performing a simple operation, and handling the response. It serves as a starting point for new integrations. ```python from yoti_sdk.client import Client # Replace with your actual SDK ID and Key File path client = Client('YOUR_SDK_ID', 'path/to/your/key.pem') # Example: Creating a document with a receipt ID receipt_id = 'some-receipt-id' document = client.get_document(receipt_id) # Process the document data (e.g., extract attributes) print(document.get_attribute('some_attribute')) ``` -------------------------------- ### Python: Yoti SDK Integration Example Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response.txt This snippet demonstrates a basic integration with the Yoti Python SDK. It typically involves initializing the SDK with credentials and making a call to a Yoti service. Ensure you have the 'yoti-sdk' package installed (`pip install yoti-sdk`). ```python from yoti_sdk.client import Client from yoti_sdk.config import Config # Replace with your actual SDK ID and PEM file path SDK_ID = "YOUR_SDK_ID" PEM_FILE = "path/to/your/pemfile.pem" # Initialize the Yoti client config = Config(SDK_ID, PEM_FILE) client = Client(config) # Example usage: Fetching a user's profile (requires a token) # Assuming you have a token obtained from a Yoti authentication flow # user_token = "some_user_token" # try: # user_data = client.get_user_data(user_token) # print(user_data) # except Exception as e: # print(f"Error fetching user data: {e}") print("Yoti SDK client initialized.") ``` -------------------------------- ### Python SDK: Basic Usage and Initialization Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt Demonstrates the fundamental steps for initializing and using the Yoti Python SDK. This typically involves setting up the SDK with credentials and performing a basic operation. It's a starting point for developers new to the SDK. ```python from yoti_sdk.yoti_client import YotiClient # Load credentials from a file (e.g., yoti_client.pem) client = YotiClient("sdk_id", "path/to/your/yoti_client.pem") # Example of a basic operation (e.g., getting user profile) # This is a placeholder and would depend on the specific Yoti API call # result = client.get_user_profile("some_user_token") # print(result) ``` -------------------------------- ### Initialize Yoti SDK Client - Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This snippet shows how to initialize the Yoti SDK client in Python. It covers the basic setup required to start using the SDK for yoti integrations. ```python from yoti_sdk.sdk import Sdk def initialize_yoti_sdk(client_id, client_sdk_key, pem_key_path): """Initializes the Yoti SDK client.""" try: sdk = Sdk(client_id, client_sdk_key, pem_key_path) print("Yoti SDK client initialized successfully.") return sdk except Exception as e: print(f"Error initializing Yoti SDK client: {e}") return None # Example usage: # client_id = "YOUR_CLIENT_ID" # client_sdk_key = "YOUR_CLIENT_SDK_KEY" # pem_key_path = "/path/to/your/sdk.pem" # yoti_sdk_client = initialize_yoti_sdk(client_id, client_sdk_key, pem_key_path) ``` -------------------------------- ### Yoti SDK Initialization and Configuration Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt This example shows the basic setup for initializing the Yoti Python SDK. It requires an SDK ID and the path to the private key file. This client object is then used for all subsequent interactions with the Yoti API. ```python from yoti_sdk.yoti_client import YotiClient # Replace with your actual SDK ID and the path to your private key file SDK_ID = "YOUR_SDK_ID" PRIVATE_KEY_PATH = "path/to/your/private.key" # Initialize the YotiClient yoti_client = YotiClient(SDK_ID, PRIVATE_KEY_PATH) # Now you can use yoti_client to interact with the Yoti API # For example: # user_data = yoti_client.get_user_data("some_token") ``` -------------------------------- ### Yoti Python SDK: Basic Usage Example Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This snippet demonstrates the fundamental usage of the Yoti Python SDK, showing how to initialize the client and perform a basic operation. It requires the 'yoti-python-sdk' library to be installed. The output depends on the specific Yoti API call being made. ```python from yoti_python_sdk import YotiClient # Replace with your SDK ID and private key path client = YotiClient("YOUR_SDK_ID", "path/to/your/private.pem") # Example: Fetching user profile data (requires appropriate Yoti integration) # user_profile = client.get_user_profile("some_token") # print(user_profile) print("Yoti client initialized successfully.") ``` -------------------------------- ### Python SDK Document Verification Example Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This snippet demonstrates how to perform document verification using the Yoti Python SDK. It involves setting up the SDK client and processing verification results. Ensure you have the Yoti SDK installed (`pip install yoti-sdk`). ```python from yoti_sdk.yoti_client import YotiClient # Replace with your SDK ID and Key File Path client = YotiClient("YOUR_SDK_ID", "path/to/your/key.pem") def verify_document(token): # Assume 'token' is obtained from the Yoti app try: activity_details = client.get_activity_details(token) document_details = activity_details.document_details return document_details except Exception as e: print(f"Error verifying document: {e}") return None # Example usage: # verification_result = verify_document("USER_TOKEN_FROM_YOTI_APP") # if verification_result: # print(verification_result) ``` -------------------------------- ### Initialize Yoti Client with SDK Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This snippet demonstrates how to initialize the Yoti client using your SDK ID. It requires the 'yoti_python_sdk' library to be installed. The client is essential for making any API calls to Yoti. ```python from yoti_python_sdk import Client # Replace with your actual SDK ID client = Client("YOUR_SDK_ID") ``` -------------------------------- ### Basic SDK Initialization in Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt Demonstrates how to initialize the Yoti SDK client using your application ID and SDK key. This is a fundamental step before making any API calls. ```python from yoti_sdk.client import Client # Replace with your actual SDK ID and Key client = Client(sdk_id='YOUR_SDK_ID', sdk_key_path='path/to/your/sdk.pem') ``` -------------------------------- ### Generate Signed URLs with Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This snippet shows how to generate signed URLs using the Yoti SDK in Python. It requires the SDK to be installed and configured with necessary credentials. ```python from yoti_sdk.yoti_client import YotiClient # Assuming you have your SDK credentials configured yoti_client = YotiClient("your_sdk_id", "path/to/your/pem/file") # Example: Generate a signed URL for an activity activity_id = "your_activity_id" activity_url = yoti_client.get_activity_url(activity_id) print(f"Signed URL: {activity_url}") ``` -------------------------------- ### Generate Token from SDK Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This snippet shows how to generate a token using the Yoti Python SDK. It requires the SDK library to be installed. The function takes an SDK instance and returns a token string. ```python from yoti_python_sdk import YotiClient def get_yoti_token(sdk): """Generates a token using the Yoti Python SDK. Args: sdk: An instance of YotiClient. Returns: A string representing the generated token. """ token = sdk.get_token() return token # Example usage: # Assuming you have your SDK details configured and an instance created # client_sdk = YotiClient(client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET") # yoti_token = get_yoti_token(client_sdk) # print(f"Yoti Token: {yoti_token}") ``` -------------------------------- ### Create Yoti Client with Configuration Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This snippet illustrates how to configure and create an instance of the Yoti client in Python. It involves providing the SDK ID and the path to the private key file. ```python from yoti_sdk.client import Client from yoti_sdk.config import Config # Replace with your actual SDK ID and the path to your private key file sdk_id = 'YOUR_SDK_ID' private_key_path = 'path/to/your/private.pem' config = Config(sdk_id=sdk_id, private_key_path=private_key_path) client = Client(config) print("Yoti client initialized successfully.") ``` -------------------------------- ### Integrate with Yoti API using Python SDK Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This snippet shows a basic integration with the Yoti API using the Python SDK. It covers authentication and making a sample API call. Proper SDK initialization with your SDK ID and private key is crucial. This example assumes a simple GET request to an endpoint. ```python from yoti_python_sdk import YotiClient def call_yoti_api(endpoint, private_key_path): try: client = YotiClient(sdk_id='YOUR_SDK_ID', private_key_path=private_key_path) response = client.get(endpoint) response.raise_for_status() # Raise an exception for bad status codes print(f"Successfully called Yoti API endpoint: {endpoint}") return response.json() except Exception as e: print(f"Error calling Yoti API: {e}") return None # Example usage: # api_endpoint = '/some/api/endpoint' # private_key_path = 'path/to/your/yoti.pem' # api_data = call_yoti_api(api_endpoint, private_key_path) # if api_data: # print("API response received.") ``` -------------------------------- ### Managing Yoti User Profiles (Python) Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt Provides examples for interacting with Yoti user profiles. This includes retrieving profile information after a user has authorized access. The SDK handles the secure retrieval and parsing of this data. ```Python from yoti_sdk.profile import Profile # Assuming 'profile_data' is the raw JSON response for a user's profile profile = Profile(profile_data) # Accessing profile attributes (example) # full_name = profile.get_full_name() # email = profile.get_email() # print(f"Full Name: {full_name}") # print(f"Email: {email}") ``` -------------------------------- ### Install Yoti Python SDK using pip Source: https://github.com/getyoti/yoti-python-sdk/blob/master/README.md This command installs the Yoti Python SDK using the pip package manager. Ensure pip is installed and accessible in your terminal. ```shell pip install yoti ``` -------------------------------- ### Creating a Document Request in Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt Provides a code example for creating a document request using the Yoti SDK. This is typically used for initiating verification processes. ```python from yoti_sdk.requests import DocumentRequest request_data = { "scenario_id": "YOUR_SCENARIO_ID", "user_token": "USER_SESSION_TOKEN" } document_request = DocumentRequest(request_data) # Use this object for API calls ``` -------------------------------- ### Install Development Dependencies for Yoti Python SDK Source: https://github.com/getyoti/yoti-python-sdk/blob/master/CONTRIBUTING.md Installs the necessary dependencies for developing and testing the Yoti Python SDK. This includes the core SDK and development-specific packages. ```bash pip install -r requirements.txt pip install -e .[dev] ``` -------------------------------- ### Create a Yoti Session (Python) Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt This code example shows how to create a new Yoti session using the Python SDK. It involves setting up the session configuration. ```python from yoti_sdk.yoti_client import YotiClient from yoti_sdk.session import SessionConfiguration # Replace with your Yoti SDK ID SDK_ID = 'YOUR_YOTI_SDK_ID' yoti_client = YotiClient(SDK_ID) # Configure the session (example: requesting user's given names and family name) session_config = SessionConfiguration([ 'given_names', 'family_name' ]) session_details = yoti_client.create_session(session_config) # session_details will contain the session ID and other relevant information ``` -------------------------------- ### Python SDK Example: Generating a Yoti Token Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This code example illustrates how to generate a Yoti token using the yoti-python-sdk. This token is crucial for initiating secure connections or authenticating with Yoti services. It requires specific credentials and configurations. ```python from yoti_python_sdk import YotiClient from yoti_python_sdk.config import YotiConfig # Assuming you have your SDK ID and Key File Path configured # Replace with your actual SDK ID and Key File Path config = YotiConfig(sdk_id="YOUR_SDK_ID", key_file_path="path/to/your/private.key") client = YotiClient(config) # Generate a token (example for demonstration, actual token generation may vary based on Yoti service) # This is a placeholder and may not represent a real token generation method. # Please refer to Yoti SDK documentation for the correct API usage. # For instance, you might be generating a token for a specific API call. # For demonstration purposes, let's assume a hypothetical token generation: # hypothetical_token = client.generate_some_token(user_id='some_user') # print(f"Hypothetical Token: {hypothetical_token}") print("Refer to Yoti SDK documentation for specific token generation methods.") ``` -------------------------------- ### SDK Initialization and Basic Usage (Python) Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt Demonstrates how to initialize the Yoti client and perform basic operations. This typically involves setting up authentication credentials and creating a client instance. No specific input or output is detailed, but it forms the foundation for SDK usage. ```Python from yoti_sdk.client import Client # Replace with your SDK ID and private key file path client = Client("YOUR_SDK_ID", "path/to/your/private.key") # Example of calling an SDK method (replace with actual method) # result = client.some_method() # print(result) ``` -------------------------------- ### Create a Yoti Document Verification Request Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This example shows how to construct a document verification request using the Yoti Python SDK. It includes setting up the client and defining the necessary parameters for the verification process. The output is a dictionary ready to be sent to the Yoti API. ```python from yoti_python_sdk import Client from yoti_python_sdk.document_prototype import DocumentPrototype client = Client("YOUR_SDK_ID") document_prototype = DocumentPrototype() # Example: Requesting identity document verification verification_request = client.create_document_verification_request(document_prototype) ``` -------------------------------- ### Create Yoti Session (Python) Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response.txt This code example shows how to create a new Yoti session. It requires the SDK configuration and a session policy to define the verification parameters. ```python from yoti_sdk.config import YotiConfig from yoti_sdk.session_policy import SessionPolicy from yoti_sdk.session_client import SessionClient config = YotiConfig(sdk_id='YOUR_SDK_ID', private_key_path='path/to/your/private.pem') policy = SessionPolicy(desired_sources=['phone', 'email', 'document'], remember_me=True) session_client = SessionClient(config) session = session_client.create_session(policy=policy) print(f"Session ID: {session['id']}") print(f"Session URL: {session['session_url']}") ``` -------------------------------- ### Python: Initialize Yoti Client Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt This snippet demonstrates how to initialize the Yoti client using your SDK ID and private key. Ensure you have the 'yoti_sdk' package installed. This is a prerequisite for all other SDK operations. ```python from yoti_sdk.client import Client # Replace with your actual SDK ID and key file path client = Client(sdk_id='YOUR_SDK_ID', key_file_path='path/to/your/private.pem') ``` -------------------------------- ### Python SDK Attribute Retrieval Example Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This snippet shows how to retrieve user attributes using the Yoti Python SDK. It requires a valid token obtained after user authentication. Make sure the `yoti-sdk` is installed. ```python from yoti_sdk.yoti_client import YotiClient # Replace with your SDK ID and Key File Path client = YotiClient("YOUR_SDK_ID", "path/to/your/key.pem") def get_user_attributes(token): try: activity_details = client.get_activity_details(token) user_profile = activity_details.user_profile return user_profile except Exception as e: print(f"Error retrieving attributes: {e}") return None # Example usage: # attributes = get_user_attributes("USER_TOKEN_FROM_YOTI_APP") # if attributes: # print(attributes) ``` -------------------------------- ### Yoti Document Authenticated Request Example Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This Python snippet shows how to make an authenticated request to the Yoti API for document details. It requires an initialized Yoti SDK client with valid credentials. The example demonstrates setting up the request and handling the response. ```python from yoti_sdk.doc_scan.client import DocScanClient from yoti_sdk.config import Config def get_authenticated_document_request(api_url, client_sdk_id, pem_key_path, document_id): """Creates an authenticated request for Yoti document details. Args: api_url (str): The base URL of the Yoti API. client_sdk_id (str): Your Yoti client SDK ID. pem_key_path (str): Path to your Yoti PEM private key. document_id (str): The ID of the document to retrieve. Returns: dict: The JSON response from the API. """ config = Config(client_sdk_id, pem_key_path) client = DocScanClient(config, api_url) response = client.get_document_details(document_id) return response.json() # Example usage: # YOTI_API_URL = 'https://api.yoti.com/...' # Replace with actual API URL # CLIENT_SDK_ID = 'YOUR_CLIENT_SDK_ID' # PEM_KEY_FILE = 'path/to/your/private.pem' # document_id_to_fetch = 'some_document_id' # doc_details = get_authenticated_document_request(YOTI_API_URL, CLIENT_SDK_ID, PEM_KEY_FILE, document_id_to_fetch) # print(doc_details) ``` -------------------------------- ### Python: Initialize Yoti Client Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This Python snippet shows the basic initialization of the YotiClient. It requires an SDK ID and the path to a PEM file containing the private key. This client object is the entry point for interacting with various Yoti SDK functionalities. ```python # from yoti_python_sdk.client import YotiClient # SDK_ID = 'your_sdk_id' # PEM_FILE = 'path/to/your/pem_file.pem' # client = YotiClient(SDK_ID, PEM_FILE) print("YotiClient initialization logic would go here.") ``` -------------------------------- ### Decrypting Yoti Data with Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This snippet demonstrates how to decrypt Yoti payload data using the Yoti Python SDK. It requires the SDK to be installed and utilizes key decryption functions. ```python from yoti_sdk.doc_scan.session_specification.session_specification import SessionSpecification from yoti_sdk.doc_scan.support.constants import SessionType from yoti_sdk.doc_scan.support.constraints import DocumentConstraints, OrthogonalConstraints from yoti_sdk.doc_scan.support.constraints import RecommendedDocuments from yoti_sdk.doc_scan.support.constraints import ZoomSlapstickConstraints from yoti_sdk.doc_scan.support.constraints import ZoomLivenessConstraints def create_session_specification_with_constraints(): session_specification = SessionSpecification( client_sdk_id='YOUR_CLIENT_SDK_ID', requirements={'aml': {'strictness': 2}}, session_type=SessionType.DESKTOP, constraints=DocumentConstraints( document_types=['PASSPORT', 'DRIVING_LICENCE'], country_codes=['GBR'], orthogonal_constraints=OrthogonalConstraints( filters=['FORCE_LUX'], recommended_documents=RecommendedDocuments( identity_document=DocumentConstraints( document_types=['PASSPORT'], country_codes=['USA'] ) ) ) ) ) return session_specification def create_session_specification_with_zoom_constraints(): session_specification = SessionSpecification( client_sdk_id='YOUR_CLIENT_SDK_ID', requirements={'aml': {'strictness': 2}}, session_type=SessionType.DESKTOP, constraints=ZoomLivenessConstraints( orthogonal_constraints=OrthogonalConstraints( zoom_slapstick_constraints=ZoomSlapstickConstraints( max_faces=1 ) ) ) ) return session_specification # Example usage: session_spec_constraints = create_session_specification_with_constraints() print(session_spec_constraints.to_json()) session_spec_zoom_constraints = create_session_specification_with_zoom_constraints() print(session_spec_zoom_constraints.to_json()) ``` -------------------------------- ### Python SDK - Create Digital Document Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt Example of creating a digital document using the Yoti Python SDK. This involves specifying the document type and content. ```python from yoti_python_sdk.document_filter import DocumentFilter, Document # Define document requirements document_filter = DocumentFilter( documents=[ Document(type='ID_DOCUMENT', country='USA', category='PASSPORT') ] ) # Assuming 'client' is an initialized Yoti client instance # This is a conceptual example; actual API call might differ # result = client.create_digital_document(document_filter=document_filter) ``` -------------------------------- ### Initialize Yoti Client in Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response.txt This snippet shows how to initialize the Yoti client with your application's SDK ID and PEM file. Ensure you have the 'yoti_sdk' package installed and the correct paths to your credentials. ```python from yoti_sdk.yoti_client import YotiClient # Replace with your SDK ID and the path to your PEM file sdk_id = "YOUR_SDK_ID" pem_file_path = "path/to/your/key.pem" # Initialize the Yoti client yoti_client = YotiClient(sdk_id, pem_file_path) print("Yoti client initialized successfully.") ``` -------------------------------- ### Initialize Yoti Client Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_missing_profile.txt Demonstrates how to initialize the Yoti client with provided SDK credentials. This is a fundamental step before making any API calls. ```python from yoti_sdk.client import Client # Replace with your actual SDK ID and key file path client = Client('your-sdk-id', 'path/to/your/key.pem') ``` -------------------------------- ### Get User Profile Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt Retrieves a user's profile data using a given token. This involves making an API call to Yoti. The function returns the parsed user profile or an error. ```python def get_user_profile(client, token): try: return client.get_user_profile(token) except Exception as e: return {'error': str(e)} ``` -------------------------------- ### Python SDK - YotiClient Initialization Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_missing_profile.txt This snippet demonstrates how to initialize the YotiClient, which is the main entry point for interacting with the Yoti API. It requires your SDK ID and either a PEM file path or a private key string for authentication. Ensure the SDK ID and key are kept secure. ```python from yoti_sdk.client import YotiClient # Using a PEM file client = YotiClient("YOUR_SDK_ID", "path/to/your/sdk.pem") # Or using a private key string # with open("path/to/your/sdk.pem", "rb") as pem_file: # pem_data = pem_file.read() # client = YotiClient("YOUR_SDK_ID", pem_data) ``` -------------------------------- ### Get Attribute from Digital Document Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt Retrieves a specific attribute from a parsed Yoti digital document. Attributes are stored as lists of 'Value' objects. This function iterates through the values to find the requested attribute. ```python def get_attribute(digital_document, attribute_name): return digital_document.attribute def get_value_from_attribute(attribute): if attribute: return attribute[0].value return None ``` -------------------------------- ### Initialize YotiClient Python SDK Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This snippet demonstrates how to initialize the YotiClient, which is the primary entry point for interacting with the Yoti API. It requires your SDK ID and a PEM file path for authentication. ```python from yoti_sdk.client import Client # Replace with your actual SDK ID and PEM file path client = Client("YOUR_SDK_ID", "path/to/your/sdk.pem") print("YotiClient initialized successfully.") ``` -------------------------------- ### Get Yoti User Profile (Python) Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response.txt This code example shows how to fetch the user's profile data from a completed Yoti session. It requires the session ID and access to the Yoti SDK configuration. ```python from yoti_sdk.config import YotiConfig from yoti_sdk.session_client import SessionClient config = YotiConfig(sdk_id='YOUR_SDK_ID', private_key_path='path/to/your/private.pem') session_client = SessionClient(config) session_id = 'YOUR_SESSION_ID' user_profile = session_client.get_user_profile(session_id=session_id) print(user_profile) ``` -------------------------------- ### Get Yoti Document Image Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This snippet shows how to retrieve an image from a Yoti document using the Yoti Python SDK. It requires a document and an image type as input. The Yoti library must be installed. ```python from yoti_sdk.document_utils import get_yoti_document_image def get_document_image(yoti_document, image_type): """Gets an image from a Yoti document. Args: yoti_document: The Yoti document. image_type: The type of image to retrieve (e.g., 'JPEG'). Returns: The image data. """ return get_yoti_document_image(yoti_document, image_type) ``` -------------------------------- ### Python SDK Initialization and Configuration Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt Demonstrates how to initialize and configure the Yoti Python SDK. This typically involves setting up client credentials and ensuring the SDK is ready for use. ```python from yoti_sdk.client import Client # Assuming you have your SDK ID and Key File path SDK_ID = "YOUR_SDK_ID" KEY_FILE_PATH = "/path/to/your/key.pem" client = Client(SDK_ID, KEY_FILE_PATH) ``` -------------------------------- ### Get Activity Details from Yoti (Python) Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This snippet illustrates how to retrieve activity details from Yoti using the client SDK. It requires the activity's receipt ID and the initialized Yoti client object. ```python from yoti_sdk.yoti_client import YotiClient yoti_client = YotiClient(client_id="YOUR_CLIENT_ID", client_sdk_key="YOUR_SDK_KEY") activity_details = yoti_client.get_activity_details(receipt_id="your_receipt_id") print(activity_details) ``` -------------------------------- ### Yoti SDK Integration Example (Python) Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This snippet demonstrates a basic integration with the Yoti SDK in Python. It may involve setting up the SDK, performing an action, and handling the response. Dependencies typically include the 'yoti' library. Input is usually a Yoti token or other identifier, and output is processed user data. ```python from yoti_python_sdk import YotiClient # Assuming you have your SDK ID and private key file path client = YotiClient("YOUR_SDK_ID", "path/to/your/private.key") # Example of calling an SDK method (replace with actual method) response = client.some_sdk_method("some_parameter") # Process the response print(response) ``` -------------------------------- ### Python: Get User Profile Data Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_missing_profile.txt This code example shows how to retrieve a user's profile data after they have successfully shared it via Yoti. It assumes you have already obtained a token or session identifier for the user. ```python from yoti_sdk.client import Client # Assuming 'client' is an authenticated Client instance # Replace 'USER_TOKEN' with the actual token obtained from the Yoti flow user_data = client.get_user_profile('USER_TOKEN') # 'user_data' will contain the profile information shared by the user # You can then parse and use this data as needed. ``` -------------------------------- ### Create Yoti Client Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt Initializes the Yoti client with SDK ID and private key. This client object is used to interact with the Yoti API. It requires the 'yoti_sdk' library and valid credentials. ```python from yoti_sdk.client import Client def create_yoti_client(sdk_id, pem_file_path): with open(pem_file_path, 'rb') as pem_file: pem_key = pem_file.read() return Client(sdk_id, pem_key) ``` -------------------------------- ### Get Yoti Document Fields Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This snippet explains how to extract specific fields from a Yoti document using the Yoti Python SDK. It takes a document and a list of desired fields as input. Ensure the Yoti library is installed. ```python from yoti_sdk.document_utils import get_yoti_document_fields def get_document_fields(yoti_document, fields): """Gets specified fields from a Yoti document. Args: yoti_document: The Yoti document. fields: A list of fields to retrieve. Returns: A dictionary of the requested document fields. """ return get_yoti_document_fields(yoti_document, fields) ``` -------------------------------- ### Yoti Python SDK - Initialize Client Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt Demonstrates how to initialize the Yoti Python SDK client with provided SDK ID and key file path. This is a crucial first step for interacting with the Yoti API. ```python from yoti_sdk.client import Client client = Client(sdk_id='YOUR_SDK_ID', key_file_path='path/to/your/key.pem') ``` -------------------------------- ### Python - Yoti Client Initialization Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt Demonstrates how to initialize the Yoti client using SDK ID and PEM key file. This is a fundamental step for interacting with Yoti services. ```python from yoti_sdk.client import YotiClient # Replace with your actual SDK ID and path to your PEM key file SDK_ID = "YOUR_SDK_ID" PEM_FILE_PATH = "path/to/your/pem/key.pem" # Initialize the Yoti client yoti_client = YotiClient(SDK_ID, PEM_FILE_PATH) ``` -------------------------------- ### Get User Profile from Yoti Python SDK Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This code example shows how to retrieve a user's profile data after they have successfully authenticated via Yoti. It involves making a request to the Yoti API using the initialized client. ```python from yoti_sdk.client import Client # Assuming 'client' is already initialized as shown in the initialization snippet # Replace 'USER_TOKEN' with the actual token obtained after user authentication user_token = "USER_TOKEN" try: user_profile = client.get_user_profile(user_token) # Process the user profile data print("User profile retrieved successfully:") # print(user_profile.get_attribute('given_name')) # Example: get a specific attribute except Exception as e: print(f"Error retrieving user profile: {e}") ``` -------------------------------- ### Initialize Yoti Client in Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt Demonstrates how to initialize the Yoti client using SDK credentials. This is a fundamental step required before making any API calls. Ensure you have your SDK ID and PEM file path correctly configured. ```python from yoti_sdk.client import Client # Replace with your actual SDK ID and PEM file path client = Client("YOUR_SDK_ID", "path/to/your/pem.pem") print("Yoti client initialized successfully.") ``` -------------------------------- ### Python: Get User Profile Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt This example demonstrates how to retrieve the user's profile information using a Yoti token. It requires an initialized Yoti client and a valid token. The function returns a dictionary containing the user's attributes. ```python from yoti_sdk.client import Client # Assuming 'client' is already initialized yoti_token = 'YOUR_YOTI_TOKEN' # Get user profile result = client.get_user_profile(yoti_token) # Process the user profile data print(result) ``` -------------------------------- ### Initialize Yoti Client SDK (Python) Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_missing_profile.txt Demonstrates how to initialize the Yoti client SDK in Python using a client SDK key. This is a prerequisite for performing any operations with the SDK. ```python from yoti_sdk.client import Client # Replace with your actual client SDK key client_sdk_key = "YOUR_CLIENT_SDK_KEY" # Initialize the Yoti client client = Client(client_sdk_key) print("Yoti client initialized successfully.") ``` -------------------------------- ### Python: Verify a Yoti Document Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This snippet demonstrates how to verify a Yoti document using the yoti-python-sdk. It requires the SDK to be installed and appropriate credentials for authentication. The function likely takes document data and a token as input, returning a verification status. ```python # Assuming you have the YotiClient initialized and have a token def verify_document(yoti_client, token): # Placeholder for actual verification logic print(f"Verifying document with token: {token}") # result = yoti_client.verify_document(token) # return result return {"status": "success", "message": "Document verified successfully"} ``` -------------------------------- ### YotiClient Initialization in Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt Demonstrates how to initialize the YotiClient using a private key. This is a fundamental step for interacting with the Yoti API. It requires the path to the private key file and the Yoti SDK ID. ```python from yoti_sdk.yoti_client import YotiClient # Load your private key and SDK ID with open("path/to/your/private.pem", "rb") as pem_file: key = pem_file.read() yoti_client = YotiClient(key, "YOUR_SDK_ID") ``` -------------------------------- ### Get User Data from Yoti Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt This code example shows how to retrieve user data after a successful Yoti authentication. It utilizes the token obtained from the Yoti client to fetch the user's profile information. Ensure the token is valid and has the necessary permissions. ```python from yoti_sdk.client import Client # Assume client is already initialized # client = Client(client_sdk_id='YOUR_SDK_ID', key_file_path='path/to/your/key.pem') def get_user_data(client, token): """Retrieves user data using an authentication token.""" user_data = client.get_user_data(token) return user_data.to_json() # Example usage: # auth_token = 'your_obtained_auth_token' # user_profile = get_user_data(client, auth_token) # print(f"User Data: {user_profile}") ``` -------------------------------- ### Initialize Yoti SDK Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt This snippet demonstrates how to initialize the Yoti SDK using a private key. It requires the SDK key and the path to the private key file. Ensure these are correctly configured for successful initialization. ```python from yoti_sdk.client import Client from yoti_sdk.config import Config # Replace with your actual SDK key and private key file path SDK_KEY = "YOUR_SDK_KEY" KEY_FILE_PATH = "/path/to/your/private.pem" config = Config(SDK_KEY, KEY_FILE_PATH) yoti_client = Client(config) print("Yoti SDK initialized successfully.") ``` -------------------------------- ### Python: Get Document Images Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt This example shows how to retrieve document images (e.g., passport, ID card) associated with a Yoti token. It requires a valid Yoti token and a pre-initialized Yoti client. The output will be a dictionary containing the image data. ```python from yoti_sdk.client import Client # Assuming 'client' is already initialized as shown previously yoti_token = 'YOUR_YOTI_TOKEN' # Get document images result = client.get_document_images(yoti_token) # Process the result (e.g., save images, extract information) print(result) ``` -------------------------------- ### Python: Yoti SDK Usage Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt Demonstrates basic usage of the Yoti Python SDK, including initialization and potential method calls. This snippet highlights common patterns for SDK integration. ```python import yoti_python_sdk def main(): # Placeholder for SDK initialization and usage print("Yoti Python SDK example") if __name__ == "__main__": main() ``` -------------------------------- ### Handle Yoti Callback and Get Token in Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt This example shows how to handle the callback from Yoti after user authentication. It extracts the authorization code from the URL and uses it to obtain an access token. This token is then used to retrieve the user's profile data. ```python from yoti_python_sdk import client # Assuming 'client' is an initialized Yoti client object # Replace with your actual SDK ID and the path to your PEM file client = client.Client('YOUR_SDK_ID', 'path/to/your/key.pem') # Assume 'auth_code' is extracted from the Yoti callback URL's query parameters # For example, if the callback URL is 'http://localhost:5000/callback?code=YOUR_AUTH_CODE&state=YOUR_STATE' auth_code = 'YOUR_AUTH_CODE' # Replace with the actual authorization code # Exchange the authorization code for an access token try: token_response = client.get_auth_token(auth_code) access_token = token_response['access_token'] print(f"Access Token: {access_token}") # Now you can use the access_token to retrieve user profile data # For example: # user_profile = client.get_user_profile(access_token) # print(user_profile) except Exception as e: print(f"Error obtaining auth token: {e}") ``` -------------------------------- ### Handle Yoti Token and Get Attribute Value in Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt This snippet demonstrates the fundamental process of handling a Yoti token and retrieving the value of a specific attribute, like 'phone_number'. It outlines the steps to access and extract data after successful authentication. ```python from yoti_sdk.attribute import Attribute def get_phone_number_from_token(decoded_token): phone_number_attr = Attribute(decoded_token.get('phone_number')) if phone_number_attr.is_present(): print(f"Phone Number: {phone_number_attr.value}") return phone_number_attr.value else: print("Phone number not found in token.") return None # Example usage (replace with actual decoded token data) # decoded_token_example = { # 'phone_number': {'value': '+441234567890', 'meta': {...}} # } # get_phone_number_from_token(decoded_token_example) ``` -------------------------------- ### Initialize Yoti Client Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_missing_profile.txt Demonstrates how to initialize the Yoti client with a private key and client SDK ID. This is a fundamental step for most SDK operations. ```python from yoti_sdk.client import Client # Replace with your actual SDK ID and private key path client_sdk_id = "YOUR_CLIENT_SDK_ID" private_key_path = "path/to/your/private.pem" client = Client(client_sdk_id, private_key_path) print("Yoti client initialized successfully.") ``` -------------------------------- ### Yoti SDK - Python Get Activity Example Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response.txt Illustrates how to retrieve an activity using the Yoti SDK. This function requires a `session_id` and `activity_id` to fetch the activity details. It returns a JSON object containing the activity data. Requires an authenticated client. ```python from yoti_sdk.client import Client # Assume 'client' is an authenticated Yoti client instance # client = Client("YOUR_SDK_ID", "path/to/your/private.pem") session_id = "example_session_id" activity_id = "example_activity_id" # This is a placeholder for the actual API call # response = client.get_activity(session_id, activity_id) # print(response) ``` -------------------------------- ### Initialize YotiClient in Python Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt Demonstrates how to initialize the YotiClient with SDK ID and private key. This is a foundational step for interacting with the Yoti API. ```python from yoti_sdk.client import YotiClient # Replace with your SDK ID and path to your private key client = YotiClient('YOUR_SDK_ID', 'path/to/your/private.pem') print('YotiClient initialized successfully!') ``` -------------------------------- ### Python SDK Initialization and Basic Usage Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_empty_profile.txt This snippet demonstrates how to initialize the Yoti Python SDK client with an SDK ID and private key. It also shows a basic example of how to use the client, potentially for making API calls. No specific dependencies are mentioned, but it's implied the 'yoti_sdk' library is required. ```python from yoti_sdk.client import Client # Initialize the client with your SDK ID and private key file path client = Client("YOUR_SDK_ID", "path/to/your/private.key") # Example of using the client (replace with actual usage) # try: # some_api_call = client.some_method() # print(some_api_call) # except Exception as e: # print(f"An error occurred: {e}") ``` -------------------------------- ### Yoti SDK - Python Get User Data Example Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response.txt Demonstrates how to retrieve user data using the Yoti SDK. This typically involves a `session_id` and an `activity_id`. The function returns a decoded user profile. Requires an authenticated client and valid session/activity IDs. ```python from yoti_sdk.client import Client # Assume 'client' is an authenticated Yoti client instance # client = Client("YOUR_SDK_ID", "path/to/your/private.pem") session_id = "example_session_id" activity_id = "example_activity_id" # This is a placeholder for the actual API call # user_data = client.get_user_data(session_id, activity_id) # print(user_data) ``` -------------------------------- ### Yoti SDK: Initializing Client Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response.txt Demonstrates how to initialize the Yoti client using your SDK ID and private key. This is a fundamental step for all subsequent operations with the Yoti API. Ensure you have your credentials securely stored. ```python from yoti_sdk.yoti_client import YotiClient # Replace with your actual SDK ID and key file path SDK_ID = "YOUR_SDK_ID" KEY_FILE = "path/to/your/private.pem" # Initialize the Yoti client yoti_client = YotiClient(SDK_ID, KEY_FILE) print("Yoti client initialized successfully.") ``` -------------------------------- ### Python SDK Initialization and Token Generation Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_missing_profile.txt Demonstrates how to initialize the Yoti Python SDK using a private key and generate a token for API requests. This typically involves loading the private key file and creating a client instance. ```python from yoti_sdk.client import Client # Load your Yoti private key with open("path/to/your/private.pem", "rb") as pem_file: private_key = pem_file.read() # Your Yoti client SDK ID client_sdk_id = "YOUR_SDK_ID" # Initialize the Yoti client yoti_client = Client(client_sdk_id, private_key) # Example: Generate a token (specific API call would follow) # token = yoti_client.get_token(...) ``` -------------------------------- ### Handle Yoti Document using Yoti Python SDK Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/response_null_profile.txt This code illustrates how to retrieve and handle a Yoti document using the Yoti Python SDK. It assumes the SDK is set up with the necessary credentials. The example shows how to get document details and then access specific attributes. ```python from yoti_sdk.doc_scan.scan_api import ScanApi def process_yoti_document(sdk, document_id): """Retrieves and processes a Yoti document. Args: sdk: The initialized Yoti SDK client. document_id (str): The ID of the document to retrieve. Returns: dict: A dictionary containing the document details. """ response = sdk.get_document_details(document_id) # Further processing of the document response can be done here return response.json() # Example usage (assuming 'yoti_client' is an initialized Yoti SDK client): # document_data = process_yoti_document(yoti_client, 'some_document_id') # print(document_data) ``` -------------------------------- ### Python - Basic SDK Usage Source: https://github.com/getyoti/yoti-python-sdk/blob/master/yoti_python_sdk/tests/fixtures/attribute_document_images.txt Demonstrates the fundamental usage of the Yoti Python SDK, including initialization and basic function calls. This snippet is essential for understanding the SDK's core structure and common patterns. ```python from yoti_sdk.yoti_client import YotiClient # Replace with your SDK ID and PEM file path client = YotiClient('sdk_id', 'sdk_pem_path') # Example of making a basic call (replace with actual method) # result = client.some_api_call() # print(result) ```