Skip to main content

Python SDK for the Reclaim Protocol

Project description

Reclaim Protocol Python SDK Integration Guide

This guide will walk you through integrating the Reclaim Protocol Python SDK into your application. We'll create a simple Python application that demonstrates how to use the SDK to generate proofs and verify claims.

Prerequisites

Before we begin, make sure you have:

  1. An application ID from Reclaim Protocol.
  2. An application secret from Reclaim Protocol.
  3. A provider ID for the specific service you want to verify.

You can obtain these details from the Reclaim Developer Portal.

Step 1: Installation

You can install this package directly from GitHub using pip:

pip install reclaim-python-sdk

Step 2: Basic Usage

Here's a simple example of how to use the SDK:

from reclaim_sdk import ReclaimProofRequest
import asyncio

async def main():
    # Initialize the SDK
    APP_ID = 'YOUR_APPLICATION_ID_HERE'
    APP_SECRET = 'YOUR_APPLICATION_SECRET_HERE'
    PROVIDER_ID = 'YOUR_PROVIDER_ID_HERE'

    proof_request = await ReclaimProofRequest.init(
        app_id=APP_ID,
        app_secret=APP_SECRET,
        provider_id=PROVIDER_ID
    )

    # Get the request URL (for QR code generation)
    request_url = await proof_request.get_request_url()
    print(f"Request URL: {request_url}")

    # Get the status URL
    status_url = proof_request.get_status_url()
    print(f"Status URL: {status_url}")


if __name__ == "__main__":
    asyncio.run(main())

Understanding the Code

Let's break down what's happening in this code:

  1. We initialize the Reclaim SDK with your application ID, secret, and provider ID.

  2. We generate a request URL using get_request_url(). This URL can be used to create a QR code.

  3. We get the status URL using get_status_url(). This URL can be used to check the status of the claim process.

Advanced Configuration

The Reclaim Python SDK offers several advanced options to customize your integration:

  1. Adding Context:

    proof_request.add_context('0x00000000000', 'Example context message')
    
  2. Setting Parameters:

    proof_request.set_params({
        'email': 'test@example.com',
        'userName': 'testUser'
    })
    
  3. Custom Redirect URL:

    proof_request.set_redirect_url('https://example.com/redirect')
    
  4. Custom Callback URL:

    proof_request.set_app_callback_url('https://example.com/callback')
    
  5. Exporting and Importing SDK Configuration:

    # Export configuration
    config_json = proof_request.to_json_string()
    print('Exportable config:', config_json)
    
    # Import configuration
    imported_request = ReclaimProofRequest.from_json_string(config_json)
    request_url = await imported_request.get_request_url()
    

Complete Example

Here's a more complete example showing various features:

from reclaim_sdk import ReclaimProofRequest
import asyncio
import qrcode

async def main():
    # Initialize SDK
    proof_request = await ReclaimProofRequest.init(
        app_id='YOUR_APP_ID',
        app_secret='YOUR_APP_SECRET',
        provider_id='YOUR_PROVIDER_ID'
    )

    # Configure the request
    proof_request.add_context('0x00000000000', 'Example context')
    proof_request.set_params({'email': 'test@example.com'})
    proof_request.set_redirect_url('https://example.com/redirect')
    proof_request.set_app_callback_url('https://example.com/callback')

    # Get request URL
    request_url = await proof_request.get_request_url()


if __name__ == "__main__":
    asyncio.run(main())

Handling Proofs on Your Backend

For production applications, it's recommended to handle proofs on your backend:

  1. Set a callback URL:

    proof_request.set_callback_url('https://your-backend.com/receive-proofs')
    
  2. Create an endpoint on your backend to receive proofs:

    from flask import Flask, request
    
    app = Flask(__name__)
    
    @app.route('/receive-proofs', methods=['POST'])
    def receive_proofs():
        proofs = request.json
        # Process the proofs
        return {'status': 'success'}
    

Next Steps

Explore the Reclaim Protocol documentation for more advanced features and best practices for integrating the SDK into your production applications.

Happy coding with Reclaim Protocol!

Contributing to Our Project

We welcome contributions to our project! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

Security Note

Always keep your Application Secret secure. Never expose it in client-side code or public repositories.

Code of Conduct

Please read and follow our Code of Conduct to ensure a positive and inclusive environment for all contributors.

Security

If you discover any security-related issues, please refer to our Security Policy for information on how to responsibly disclose vulnerabilities.

Contributor License Agreement

Before contributing to this project, please read and sign our Contributor License Agreement (CLA).

Indie Hackers

For Indie Hackers: Check out our guidelines and potential grant opportunities

License

This project is licensed under a custom license. By contributing to this project, you agree that your contributions will be licensed under its terms.

Thank you for your contributions!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reclaim_python_sdk-1.0.3.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reclaim_python_sdk-1.0.3-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file reclaim_python_sdk-1.0.3.tar.gz.

File metadata

  • Download URL: reclaim_python_sdk-1.0.3.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.13

File hashes

Hashes for reclaim_python_sdk-1.0.3.tar.gz
Algorithm Hash digest
SHA256 111c634cf85f801d8af4348f15986e05d26676c14e359a1b4359e8bd0b369986
MD5 ae92b4805dd3cc9ee584578774cb0dfa
BLAKE2b-256 47a28c426fcf33a7e30d070fc5a771c974fb8943fb9f75b2be2ce0b8e8d9268b

See more details on using hashes here.

File details

Details for the file reclaim_python_sdk-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for reclaim_python_sdk-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1d2bbc266c17f07a5e9dd872ccb4596934c68c7088337e96208d454806622a3d
MD5 ef81c1e9acc3401936dab03a5243f49e
BLAKE2b-256 bca70e3e1ef8f9da01f7bf520660f084c97e3cb03c9c0ad0e819c6f1e07784d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page