Search code examples
pythonauthlib

Mongodb support in authlib


I have learned how lepture's authlib works and i have little bit obstacle, there are model mixin like Authorizationcode etc. for SQLAlchemy in the library but it's designed for sqla, is it possible to implement authlib in mongodb? thank you


Solution

  • Yes. You just need to implement the missing methods for ClientMixin, AuthorizationCodeMixin and TokenMixin.

    On documentation https://docs.authlib.org/en/latest/flask/2/authorization-server.html there are sentences like:

    1. A client is registered by a user (developer) on your website. If you decide to implement all the missing methods by yourself, get a deep inside with ClientMixin API reference.
    2. If you decide to implement all the missing methods by yourself, get a deep inside with TokenMixin API reference.

    Here are the mixins:

    1. https://docs.authlib.org/en/latest/specs/rfc6749.html#authlib.oauth2.rfc6749.ClientMixin
    2. https://docs.authlib.org/en/latest/specs/rfc6749.html#authlib.oauth2.rfc6749.TokenMixin
    3. https://docs.authlib.org/en/latest/specs/rfc6749.html#authlib.oauth2.rfc6749.AuthorizationCodeMixin

    Checkout https://github.com/opendatateam/udata This project is using mongodb.