frontegg / python-sdk Goto Github PK
View Code? Open in Web Editor NEWFrontegg python SDK
License: MIT License
Frontegg python SDK
License: MIT License
Hey,
Because of import issue, in order to make this package work - we must install Flask as well (while we don't need it).
That’s because the file _mixins.py which has the following import:
from flask import request
So when using frontegg package, it calls init.py file which imports the _mixins.py file and if flask is not installed it wil raise an exception.
You can the see the following stacktrace:
Traceback (most recent call last):
File "/Users/noam/PycharmProjects/runtime/backend/main.py", line 9, in <module>
from frontegg.fastapi import frontegg
File "/Users/noam/PycharmProjects/venvs/runtime/lib/python3.8/site-packages/frontegg/__init__.py", line 2, in <module>
from frontegg.client import FronteggRESTClient, FronteggClient, FronteggContext
File "/Users/noam/PycharmProjects/venvs/runtime/lib/python3.8/site-packages/frontegg/client.py", line 10, in <module>
from frontegg._mixins import AuditsClientMixin, SSOClientMixin
File "/Users/noam/PycharmProjects/venvs/runtime/lib/python3.8/site-packages/frontegg/_mixins.py", line 5, in <module>
from flask import request
ModuleNotFoundError: No module named 'flask'
The solution is only use the “flask” package under the “flask” folder, and don’t call the flask/fastapi folder modules in the main package init file
You can reproduce the issue if you install the following pages: fastapi, frontegg and use your example code (in an isolated environment without flask)
Thanks
Hey!
Currently, the Frontegg Python package is writing logs to the "Frontegg" logger, and in addition you specify the format and handler.
However, doing so in a package causes lack of control of the loggers, I can't use my own logger.
The best practice around this area is not to specify logging handler or format, just use getLogger and that's it. The user of this package should specify the logging format and handler.
I think a good change is to have logger.py be:
import logging
logger = logging.getLogger('Frontegg')
And for your own tests you can just set the logger settings.
Thanks,
Amit.
Currently, the library supports Flask, aiohttp, and FastAPI.
Need to add support for sanic as well
Hi,
Could you consider loosening your dependancies unless there are technical reasons to do so? For example right now cryptography v42 cannot be installed alongside frontegg v3.0.0. Instead of specifying^41.0
could you set a minimum version or just *
if that works?
python3.11/site-packages/frontegg/flask/frontegg.py", line 18, in should_refresh_vendor_token
return self.authenticator.should_refresh_vendor_token()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'bool' object is not callable
Can you please support httpx 0.27.0? Seems like there aren't any breaking changes.
Thank you :)
After an upgrade to Frontegg version 3.0.0
my authentication calls started failing.
So I came to this repo and changed my fastapi app startup using a startup_event function. But that didn't work either.
FastAPI version 0.92.0
I had to instead add it to a lifespan function as follows:
@asynccontextmanager
async def lifespan(app: FastAPI):
"""
This function is used to run a task in the background for the entire lifespan of the application.
Args:
app (FastAPI): FastAPI application instance
frontend.init_app() is used to initialize the Frontegg SDK.
"""
print("Starting lifespan...")
await frontegg.init_app(client_id=FRONTEGG_CLIENT_ID, api_key=FRONTEGG_API_KEY)
try:
yield
finally:
print("Stopping lifespan...")
app = FastAPI(debug=True, lifespan=lifespan)
Is it possible somehow to implement integration with django?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.