codemation / easyauth

Create a centralized Authentication and Authorization token server. Easily secure FastAPI endpoints based on Users, Groups, Roles or Permissions with very little database usage.
https://easyauth.readthedocs.io/en/latest/
MIT License
553 stars 52 forks source link

Error on loading a app #82

Open Hybridhash opened 1 year ago

Hybridhash commented 1 year ago

I have attempted to install easy auth in an existing fast API project. There are the following 2 issues encountered:

  1. Pip/Poetry add do not install all dependencies. The following dependencies are getting missed and need to be installed using pip or poetry one by one.
  1. Secondly, I am getting the below error on starting the server. Not sure what is causing this problem

`ERROR: Traceback (most recent call last): File "/Users/ahmad/Library/CloudStorage/OneDrive-Personal/Coding/FastApi/blog-app/.venv/lib/python3.10/site-packages/starlette/routing.py", line 671, in lifespan async with self.lifespan_context(app): File "/Users/ahmad/Library/CloudStorage/OneDrive-Personal/Coding/FastApi/blog-app/.venv/lib/python3.10/site-packages/starlette/routing.py", line 566, in aenter await self._router.startup() File "/Users/ahmad/Library/CloudStorage/OneDrive-Personal/Coding/FastApi/blog-app/.venv/lib/python3.10/site-packages/starlette/routing.py", line 648, in startup await handler() File "/Users/ahmad/Library/CloudStorage/OneDrive-Personal/Coding/FastApi/blog-app/./blog/main.py", line 26, in startup app.auth = await EasyAuthServer.create( File "/Users/ahmad/Library/CloudStorage/OneDrive-Personal/Coding/FastApi/blog-app/.venv/lib/python3.10/site-packages/easyauth/server.py", line 225, in create auth_server = cls( File "/Users/ahmad/Library/CloudStorage/OneDrive-Personal/Coding/FastApi/blog-app/.venv/lib/python3.10/site-packages/easyauth/server.py", line 107, in init self.load_env_from_file(env_from_file) File "/Users/ahmad/Library/CloudStorage/OneDrive-Personal/Coding/FastApi/blog-app/.venv/lib/python3.10/site-packages/easyauth/server.py", line 362, in load_env_from_file env_file = json.load(json_env) File "/Users/ahmad/.pyenv/versions/3.10.9/lib/python3.10/json/init.py", line 293, in load return loads(fp.read(), File "/Users/ahmad/.pyenv/versions/3.10.9/lib/python3.10/json/init.py", line 346, in loads return _default_decoder.decode(s) File "/Users/ahmad/.pyenv/versions/3.10.9/lib/python3.10/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/Users/ahmad/.pyenv/versions/3.10.9/lib/python3.10/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

ERROR: Application startup failed. Exiting.`

Envoirnemnt specification python: 3.10.9 OS: MacOS

codemation commented 11 months ago

Hi @Hybridhash ,

1.) I would make sure that PIP is up to date on your machine, poetry is less tested right now. I expect to clean up a bit of the dependencies with future bumps of DB layer.

2) It looks like env_from_file was specified when creating the server, but the file was not found. A good candidate for a future improvement / error handling. Thanks for reporting.

codemation commented 11 months ago