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.
Before we begin, make sure you have:
- An application ID from Reclaim Protocol.
- An application secret from Reclaim Protocol.
- A provider ID for the specific service you want to verify.
You can obtain these details from the Reclaim Developer Portal.
You can install this package directly from GitHub using pip:
pip install reclaim-python-sdk
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())
Let's break down what's happening in this code:
-
We initialize the Reclaim SDK with your application ID, secret, and provider ID.
-
We generate a request URL using
get_request_url()
. This URL can be used to create a QR code. -
We get the status URL using
get_status_url()
. This URL can be used to check the status of the claim process.
The Reclaim Python SDK offers several advanced options to customize your integration:
-
Adding Context:
proof_request.add_context('0x00000000000', 'Example context message')
-
Setting Parameters:
proof_request.set_params({ 'email': 'test@example.com', 'userName': 'testUser' })
-
Custom Redirect URL:
proof_request.set_redirect_url('https://example.com/redirect')
-
Custom Callback URL:
proof_request.set_app_callback_url('https://example.com/callback')
-
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()
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())
For production applications, it's recommended to handle proofs on your backend:
-
Set a callback URL:
proof_request.set_callback_url('https://your-backend.com/receive-proofs')
-
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'}
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!
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.
Always keep your Application Secret secure. Never expose it in client-side code or public repositories.
Please read and follow our Code of Conduct to ensure a positive and inclusive environment for all contributors.
If you discover any security-related issues, please refer to our Security Policy for information on how to responsibly disclose vulnerabilities.
Before contributing to this project, please read and sign our Contributor License Agreement (CLA).
For Indie Hackers: Check out our guidelines and potential grant opportunities
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!