Closed YogeshUpdhyay closed 2 years ago
from authx import Authentication, MongoDBBackend import motor.motor_asyncio import asyncio auth = Authentication( backend=MongoDBBackend( client=motor.motor_asyncio.AsyncIOMotorClient( 'mongodb://localhost:27017', io_loop=asyncio.get_event_loop() ), database='authx', collection='users' ) )
This should ideally create an auth object that can be used to include routers. Instead this gives an error
backend=MongoDBBackend( TypeError: __init__() got an unexpected keyword argument 'client'
Windows
No response
0.77.1
Python 3.9.0
This problem is arising as the MongoDBBackend class is not excepting any other parameters other than the database_name
class MongoDBBackend(BaseDBBackend): """ Setup Database for authx using MongoDB & Motor """ def __init__(self, database_name: str = "test") -> None: self._database_name = database_name def set_client(self, client: AsyncIOMotorClient) -> None: self._client = client self.init() def init(self) -> None: self._db: AsyncIOMotorDatabase = self._client[self._database_name] self._users: AsyncIOMotorCollection = self._db["users"] self._email_confirmations: AsyncIOMotorCollection = self._db[ "email_confirmations" ] self._counters: AsyncIOMotorCollection = self._db["counters"] self._settings: AsyncIOMotorCollection = self._db["settings"]
hello @YogeshUpdhyay can you please check the PR I mention #260
First Check
Example Code
Description
This should ideally create an auth object that can be used to include routers. Instead this gives an error
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.77.1
Python Version
Python 3.9.0
Additional Context
This problem is arising as the MongoDBBackend class is not excepting any other parameters other than the database_name