Name | abs-integration-core JSON |
Version |
0.1.14
JSON |
| download |
home_page | None |
Summary | Core utilities for building OAuth-based integrations in FastAPI applications |
upload_time | 2025-07-22 16:53:30 |
maintainer | None |
docs_url | None |
author | AutoBridgeSystems |
requires_python | <4.0,>=3.13 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Integration Core
A core library for building and managing OAuth-based third-party integrations in FastAPI applications.
## Overview
`abs-integration-core` provides a set of reusable components to simplify the implementation of OAuth-based integrations with third-party services. It includes models, schemas, repositories, and a base service class that can be extended for specific integration providers.
## Features
- **Integration Model**: SQLAlchemy model for storing OAuth tokens and integration metadata
- **Standard Schemas**: Pydantic models for integration data validation and serialization
- **Repository Layer**: Data access layer for CRUD operations on integration records
- **Base Service**: Abstract base class for implementing integration services for different providers
- **Token Verification**: Automatic handling of token expiration and refresh
## Installation
```bash
pip install abs-integration-core
```
## Dependencies
This package depends on:
- `fastapi`: For API routing and endpoint handling
- `sqlalchemy`: For database ORM functionality
- `pydantic`: For data validation
- `abs-exception-core`: For standardized exception handling
- `abs-repository-core`: For base repository pattern implementation
- `abs-auth-rbac-core`: For authentication and base models
## Usage
### Models
The core model represents an OAuth integration with a third-party provider:
```python
from abs_integration_core.models import Integration
# The Integration model includes:
# - provider_name: String(255)
# - access_token: Text
# - refresh_token: Text
# - expires_at: DateTime
```
### Schemas
Various Pydantic schemas are available for request/response handling:
```python
from abs_integration_core import (
TokenData,
IsConnectedResponse,
CreateIntegration,
UpdateIntegration,
ResponseSchema
)
# TokenData includes:
# - access_token: str
# - refresh_token: str
# - expires_at: datetime
# Example: Create a standard API response
response = ResponseSchema(
status=200,
message="Integration created successfully",
data=IsConnectedResponse(provider="sharepoint", connected=True)
)
```
### Repository
The `IntegrationRepository` provides data access methods:
```python
from abs_integration_core import IntegrationRepository
# Initialize repository with a database session factory
repo = IntegrationRepository(db_session)
# Available methods:
# - create_integration(integration_data)
# - update_integration(integration_id, update_data)
# - get_by_provider(provider_name)
# - get_all()
# - delete_by_provider(provider_name)
# - refresh_token(provider_name, token_data)
```
### Base Service
Extend the `IntegrationBaseService` to implement provider-specific integration services:
```python
from abs_integration_core import IntegrationBaseService
class SharepointIntegrationService(IntegrationBaseService):
def __init__(self, provider_name, integration_repository, encryption):
super().__init__(provider_name, integration_repository, encryption)
def get_auth_url(self, state=None):
# Implementation for generating OAuth URL
async def get_token_data(self, code):
# Implementation for exchanging code for tokens
async def handle_oauth_callback(self, code):
# Implementation for processing OAuth callback
async def refresh_token(self):
# Implementation for refreshing tokens
```
## Implementing a New Integration
To implement a new integration provider:
1. Create a new service class that extends `IntegrationBaseService`
2. Implement the required abstract methods:
- `get_auth_url()`
- `get_token_data(code)`
- `handle_oauth_callback(code)`
- `refresh_token()`
3. Register your service in your FastAPI application
4. Create API routes to initiate auth flow, handle callbacks, etc.
## Example: Creating API Routes
```python
from fastapi import APIRouter, Depends
from abs_integration_core import ResponseSchema, IsConnectedResponse
router = APIRouter(prefix="/integration", tags=["integration"])
@router.get("/{provider_name}/connect")
async def integration_connect(
service: IntegrationBaseService = Depends(get_integration_service)
):
auth_data = service.get_auth_url()
return RedirectResponse(url=auth_data["auth_url"])
@router.get("/{provider_name}/callback")
async def integration_callback(
code: str,
service: IntegrationBaseService = Depends(get_integration_service)
):
token_data = await service.handle_oauth_callback(code)
return ResponseSchema(
data=IsConnectedResponse(
provider=service.provider_name,
connected=True
),
message=f"Integration connected successfully"
)
```
## License
MIT
Raw data
{
"_id": null,
"home_page": null,
"name": "abs-integration-core",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.13",
"maintainer_email": null,
"keywords": null,
"author": "AutoBridgeSystems",
"author_email": "info@autobridgesystems.com",
"download_url": "https://files.pythonhosted.org/packages/be/5b/370d535727d85a063753488a7d53f029a79d3e4a682b7556efb22b9ac964/abs_integration_core-0.1.14.tar.gz",
"platform": null,
"description": "# Integration Core\n\nA core library for building and managing OAuth-based third-party integrations in FastAPI applications.\n\n## Overview\n\n`abs-integration-core` provides a set of reusable components to simplify the implementation of OAuth-based integrations with third-party services. It includes models, schemas, repositories, and a base service class that can be extended for specific integration providers.\n\n## Features\n\n- **Integration Model**: SQLAlchemy model for storing OAuth tokens and integration metadata\n- **Standard Schemas**: Pydantic models for integration data validation and serialization\n- **Repository Layer**: Data access layer for CRUD operations on integration records\n- **Base Service**: Abstract base class for implementing integration services for different providers\n- **Token Verification**: Automatic handling of token expiration and refresh\n\n## Installation\n\n```bash\npip install abs-integration-core\n```\n\n## Dependencies\n\nThis package depends on:\n\n- `fastapi`: For API routing and endpoint handling\n- `sqlalchemy`: For database ORM functionality\n- `pydantic`: For data validation\n- `abs-exception-core`: For standardized exception handling\n- `abs-repository-core`: For base repository pattern implementation\n- `abs-auth-rbac-core`: For authentication and base models\n\n## Usage\n\n### Models\n\nThe core model represents an OAuth integration with a third-party provider:\n\n```python\nfrom abs_integration_core.models import Integration\n\n# The Integration model includes:\n# - provider_name: String(255)\n# - access_token: Text\n# - refresh_token: Text \n# - expires_at: DateTime\n```\n\n### Schemas\n\nVarious Pydantic schemas are available for request/response handling:\n\n```python\nfrom abs_integration_core import (\n TokenData,\n IsConnectedResponse,\n CreateIntegration,\n UpdateIntegration,\n ResponseSchema\n)\n\n# TokenData includes:\n# - access_token: str\n# - refresh_token: str\n# - expires_at: datetime\n\n# Example: Create a standard API response\nresponse = ResponseSchema(\n status=200,\n message=\"Integration created successfully\",\n data=IsConnectedResponse(provider=\"sharepoint\", connected=True)\n)\n```\n\n### Repository\n\nThe `IntegrationRepository` provides data access methods:\n\n```python\nfrom abs_integration_core import IntegrationRepository\n\n# Initialize repository with a database session factory\nrepo = IntegrationRepository(db_session)\n\n# Available methods:\n# - create_integration(integration_data)\n# - update_integration(integration_id, update_data)\n# - get_by_provider(provider_name)\n# - get_all()\n# - delete_by_provider(provider_name)\n# - refresh_token(provider_name, token_data)\n```\n\n### Base Service\n\nExtend the `IntegrationBaseService` to implement provider-specific integration services:\n\n```python\nfrom abs_integration_core import IntegrationBaseService\n\nclass SharepointIntegrationService(IntegrationBaseService):\n def __init__(self, provider_name, integration_repository, encryption):\n super().__init__(provider_name, integration_repository, encryption)\n \n def get_auth_url(self, state=None):\n # Implementation for generating OAuth URL\n \n async def get_token_data(self, code):\n # Implementation for exchanging code for tokens\n \n async def handle_oauth_callback(self, code):\n # Implementation for processing OAuth callback\n \n async def refresh_token(self):\n # Implementation for refreshing tokens\n```\n\n## Implementing a New Integration\n\nTo implement a new integration provider:\n\n1. Create a new service class that extends `IntegrationBaseService`\n2. Implement the required abstract methods:\n - `get_auth_url()`\n - `get_token_data(code)`\n - `handle_oauth_callback(code)`\n - `refresh_token()`\n3. Register your service in your FastAPI application\n4. Create API routes to initiate auth flow, handle callbacks, etc.\n\n## Example: Creating API Routes\n\n```python\nfrom fastapi import APIRouter, Depends\nfrom abs_integration_core import ResponseSchema, IsConnectedResponse\n\nrouter = APIRouter(prefix=\"/integration\", tags=[\"integration\"])\n\n@router.get(\"/{provider_name}/connect\")\nasync def integration_connect(\n service: IntegrationBaseService = Depends(get_integration_service)\n):\n auth_data = service.get_auth_url()\n return RedirectResponse(url=auth_data[\"auth_url\"])\n\n@router.get(\"/{provider_name}/callback\")\nasync def integration_callback(\n code: str,\n service: IntegrationBaseService = Depends(get_integration_service)\n):\n token_data = await service.handle_oauth_callback(code)\n return ResponseSchema(\n data=IsConnectedResponse(\n provider=service.provider_name,\n connected=True\n ),\n message=f\"Integration connected successfully\"\n )\n```\n\n## License\n\nMIT ",
"bugtrack_url": null,
"license": "MIT",
"summary": "Core utilities for building OAuth-based integrations in FastAPI applications",
"version": "0.1.14",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3029689dbc57262c4e78014dffb169fc73c84e78fa46e5e97d536ec248ebc0fa",
"md5": "d94b7277a006004cd6a853109c9d0a8a",
"sha256": "6d3e557442e6247d37a0b22e4a50067b45d1ad8ce0809f93a8ca812fe067ba83"
},
"downloads": -1,
"filename": "abs_integration_core-0.1.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d94b7277a006004cd6a853109c9d0a8a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.13",
"size": 41792,
"upload_time": "2025-07-22T16:53:27",
"upload_time_iso_8601": "2025-07-22T16:53:27.236131Z",
"url": "https://files.pythonhosted.org/packages/30/29/689dbc57262c4e78014dffb169fc73c84e78fa46e5e97d536ec248ebc0fa/abs_integration_core-0.1.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "be5b370d535727d85a063753488a7d53f029a79d3e4a682b7556efb22b9ac964",
"md5": "38bbb9faa23c1b021c60085131e8d59b",
"sha256": "01e3aac30ab4009f7f8113ee6fae5b0bb9ffb39baa188de515f8f3858b5e076d"
},
"downloads": -1,
"filename": "abs_integration_core-0.1.14.tar.gz",
"has_sig": false,
"md5_digest": "38bbb9faa23c1b021c60085131e8d59b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.13",
"size": 26255,
"upload_time": "2025-07-22T16:53:30",
"upload_time_iso_8601": "2025-07-22T16:53:30.179071Z",
"url": "https://files.pythonhosted.org/packages/be/5b/370d535727d85a063753488a7d53f029a79d3e4a682b7556efb22b9ac964/abs_integration_core-0.1.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-22 16:53:30",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "abs-integration-core"
}