Adding and Managing Connectors
In the Fiscus SDK, connectors play a crucial role in interacting with external APIs or services. These connectors represent integrations with platforms like Gmail, Salesforce, or any other service that you wish to connect your users to. Managing these connectors efficiently is key to creating scalable, secure, and personalized API interactions.
This section covers the process of adding new connectors, managing them at scale, and ensuring smooth integration with various APIs.
Creating New API Integrations
Adding a connector in the Fiscus SDK allows your users to interact with different services. Each connector is linked to a specific user, ensuring that API interactions are personalized and secure.
Use Case: Why Add Connectors?
- Service Personalization: Different users may need access to different services based on their roles or subscription plans. Connectors allow you to dynamically assign these services to individual users.
- Expanding Features: You can easily introduce new features by adding connectors to external services, such as email platforms, payment gateways, or CRMs.
- Security and Isolation: Each connector is isolated per user, meaning sensitive data or tokens are securely managed within the scope of a user's session.
How to Add a Connector
To add a connector, use the add_connector method. This registers the new connector under a specific user, making it ready for use in any operation.
- Python
Example: Adding a Gmail Connector
Add a Gmail connector for a user:
user.add_connector('gmail')
Example: Adding a Salesforce Connector
Add a Salesforce connector for a user:
user.add_connector('salesforce')
Error Handling When Adding Connectors
The Fiscus SDK ensures that duplicate connectors are not added for the same user. If a connector has already been added, it will log a warning and skip the addition. This prevents unnecessary duplication.
Handling connector duplication:
user.add_connector('gmail')
# If Gmail was already added, logs a warning and skips
Once a connector is successfully added, it's ready for authentication and subsequent API calls.
Managing Connectors at Scale
As your application grows, managing connectors for multiple users across different services can become complex. The Fiscus SDK provides robust tools to handle this complexity, allowing you to scale efficiently while maintaining control over connector usage.
Use Case: Why Manage Connectors at Scale?
- Enterprise Applications: In a multi-tenant SaaS platform, different users or organizations may need access to a variety of connectors. Managing connectors at scale allows you to assign and remove integrations dynamically across different teams or departments.
- API Governance: You may want to enforce policies regarding which connectors are available, monitor usage, or deactivate unused connectors to optimize performance and security.
- User Flexibility: Allow users to connect and disconnect from services as needed without affecting others in the system.
Listing Connected Connectors
You can list all connectors currently associated with a user, providing visibility into the services they have access to. This is particularly useful for auditing and debugging purposes.
Example: Listing All Connectors for a User
connected_services = user.list_connected_connectors()
print("User is connected to:", connected_services)
Example Use Case: Auditing Connectors for a User
In an enterprise application, it’s essential to audit which services users are connected to in order to maintain compliance with security protocols or usage policies.
Audit connected services:
for connector in user.list_connected_connectors():
print(f"User has access to: {connector}")
Removing Connectors
Removing connectors that are no longer needed or relevant is essential to keep your system lean, secure, and compliant with security standards.
Example: Removing a Connector for a User
Remove a Gmail connector for a user:
user.remove_connector('gmail')
Example: Removing an Unused Connector
If a connector is no longer used, removing it can free up resources and improve security.
user.remove_connector('OldAPI')
Automating Connector Management
For larger systems, it might be useful to automate connector management based on user roles, subscription levels, or activity. Using Fiscus SDK's flexible user management, you can assign or remove connectors dynamically based on these criteria.
Example: Automating Connector Assignment Based on User Role
Automatically assign the CRM system to admin users:
if 'admin' in user.roles:
user.add_connector('CRMSystem')
Conclusion
- Adding connectors allows users to interact with personalized external services based on their needs and roles.
- Managing connectors at scale ensures efficiency, security, and flexibility in large applications.
- Listing and removing connectors enables you to audit and optimize resource usage, ensuring only necessary services are active.
By creating new API integrations through connectors and managing them at scale, you can build a flexible, secure, and scalable infrastructure that adapts to the needs of your users. Whether you're managing a few services or hundreds, the Fiscus SDK gives you the tools to handle connectors with ease, ensuring your system remains robust and future-proof.