Observed since 20 Oct, 17:37 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
abs-nosql-integration-core
Core utilities for building OAuth-based integrations in FastAPI applications with use of NoSql db
A comprehensive library for building OAuth-based integration services with NoSQL databases in FastAPI applications.
NoSQL Integration Core extends the base Integration Core library to provide specialized support for NoSQL databases like MongoDB. It simplifies the process of managing OAuth tokens, API credentials, and integration state while leveraging the flexibility and scalability of NoSQL databases.
# Using pip
pip install abs-nosql-integration-core
# Using Poetry
poetry add abs-nosql-integration-core
The package follows a modular architecture:
from abs_nosql_integration_core.service import IntegrationBaseService
from abs_nosql_integration_core.repository import IntegrationRepository
from abs_integration_core.utils.encryption import Encryption
# Create an integration service
class MyIntegrationService(IntegrationBaseService):
def __init__(
self,
provider_name: str,
integration_repository: IntegrationRepository,
encryption: Encryption
):
super().__init__(provider_name, integration_repository, encryption)
# Additional provider-specific configuration
from dependency_injector import containers, providers
from abs_nosql_integration_core.repository import IntegrationRepository
from abs_integration_core.utils.encryption import Encryption
class Container(containers.DeclarativeContainer):
# MongoDB initialization
mongodb_client = providers.Singleton(
MongoClient,
connection_string=settings.MONGODB_CONNECTION_STRING
)
# Encryption service
encryption = providers.Singleton(
Encryption,
secret_key=settings.ENCRYPTION_KEY
)
# Repository layer
integration_repository = providers.Singleton(IntegrationRepository)
# Service layer
my_integration_service = providers.Singleton(
MyIntegrationService,
provider_name="my_provider",
integration_repository=integration_repository,
encryption=encryption
)
from fastapi import Depends, FastAPI, APIRouter
from dependency_injector.wiring import inject, Provide
router = APIRouter()
@router.get("/connect")
async def connect(
service: IntegrationBaseService = Depends(get_integration_service),
):
auth_url = service.get_auth_url()
return {"auth_url": auth_url}
@router.get("/callback")
async def callback(
code: str,
service: IntegrationBaseService = Depends(get_integration_service),
):
token_data = await service.handle_oauth_callback(code)
return {"status": "connected"}
The integration document model includes:
class IntegrationDocument(BaseDraftDocument):
provider_name: str # Name of the integration provider
access_token: str # OAuth access token (encrypted)
refresh_token: str # OAuth refresh token (encrypted)
expires_at: datetime # Token expiration date
The IntegrationRepository class provides:
create_integration: Create a new integration recordrefresh_token: Update access and refresh tokensget_query_by_provider: Find an integration by provider nameget_integration: Get a single integration by providerget_all_integrations: Get all integrationsdelete_integration: Remove an integrationThe IntegrationBaseService class provides:
get_auth_url: Generate OAuth authorization URLhandle_oauth_callback: Process OAuth callback and store tokensrefresh_token: Refresh expired access tokensget_integration: Get current integration detailsdelete_integration: Remove integration and related tokensThe library uses a standard exception hierarchy:
NotFoundError: Integration not foundBadRequestError: Invalid request parametersDuplicatedError: Integration already existsUnauthorizedError: Authentication issuesThe package supports MongoDB through Beanie ODM:
from beanie import init_beanie
from motor.motor_asyncio import AsyncIOMotorClient
from abs_nosql_integration_core.model import IntegrationDocument
async def init_mongodb():
# Create Motor client
client = AsyncIOMotorClient(MONGODB_URL)
# Initialize Beanie with document models
await init_beanie(
database=client.db_name,
document_models=[IntegrationDocument]
)
Contributions are welcome! Please feel free to submit pull requests.
This project is licensed under the MIT License.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
abs-exception-coreEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.11",
"evaluation": "NOT_EVALUATED"
} | abs-exception-core<0.4.0,>=0.3.0 | runtime |
abs-integration-coreEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.11",
"evaluation": "NOT_EVALUATED"
} | abs-integration-core<1.0.0,>=0.3.0 | runtime |
abs-nosql-repository-coreEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.11",
"evaluation": "NOT_EVALUATED"
} | abs-nosql-repository-core<0.13.0,>=0.12.0 | runtime |
fastapiEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.11",
"evaluation": "NOT_EVALUATED"
} | fastapi<2.0.0,>=0.130.0 | runtime |
httpxEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.11",
"evaluation": "NOT_EVALUATED"
} | httpx<0.29.0,>=0.28.1 | runtime |
pydanticEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.11",
"evaluation": "NOT_EVALUATED"
} | pydantic<3.0.0,>=2.0.0 | runtime |
starletteEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.11",
"evaluation": "NOT_EVALUATED"
} | starlette>=0.49.1 | runtime |
bdist_wheel · 16.94 KB · Python py3
sdist · 9.76 KB · Python source
Observed since 20 Oct, 17:37 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:f1cdd680e1291029eb18a7ddad4eab303e6c43256ddcb849fba73e55c97bb8ed