Questions tagged [fastapiusers]

Use this tag for questions about the fastapi-users package.

The documentation for the fastapi-users project may be found here.

16 questions
5
votes
1 answer

Pydantic returns 'field required (type=value_error.missing)' on an Optional field with a custom model

I'm trying to build a custom field in Fastapi-users pydantic schema as follows: class UserRead(schemas.BaseUser[uuid.UUID]): twitter_account: Optional['TwitterAccount'] On UserRead validation Pydantic returns field required…
Jakub Królikowski
  • 403
  • 1
  • 7
  • 16
2
votes
0 answers

Fast API Role based access control and best practices to maintian backend structure

Im new to fastapi. So created a basic api (login/register/view_items) for my requirements from a tutorial. Project Structure Issue 1: My login endpoint returns a Bearer token in json body once i login with valid creds. I have to manually add the…
Sunil Raj
  • 43
  • 4
2
votes
1 answer

ImportError: FastAPI-users

From https://frankie567.github.io/fastapiusers/ - has anyone else got this to work with tortoise ORM? Can you share the config with me as I am getting this error: module = importlib.import_module(module_str) File…
RodgerThat
  • 19
  • 1
  • 4
1
vote
0 answers

Google OAuth integration with fastapi

We use fastapi-users to integrate Google auth. By default there are defined to endpoints /auth/google/authorize and /auth/google/callback. So frontend which is in Angular calls /auth/google/authorize and as result we got URL in body. Than if we call…
1
vote
2 answers

init_beanie cannot initialize some collections

Having a well described model and schema using Pydantic and Beanie syntax, there are some collections, represented by their Document classes, which are not been initialized by init_beanie function at the startup event of a Fastapi app. Did someone…
0
votes
1 answer

How can make api using fastapi for django project

I want my projects to be more faster and i decided to use fastapi for them.But can't import my django models and form to fastapi.can someone help me to make api using fastapi for django projects? any code? (for example blog project)
0
votes
1 answer

"Runtime Error: Event loop is closed" during testing using Pytest

Please help me. How to fix it? The error appears only when using cookies in test_logout() conftest.py ............... @pytest_asyncio.fixture(autouse=True, scope='session') async def prepare_database(): async with engine_test.begin() as conn: …
0
votes
2 answers

fastapi lifespan closing session raises AttributeError: 'SQLAlchemyUserDatabase' object has no attribute 'close'

I am using fastapi (0.95.0), fastapi-users (10.4.2), fastapi-users-db-sqlalchemy (5.0.0) and SQLAlchemy (2.0.10) in my application. This is a simplified snippet of my code: engine = create_async_engine(SQLALCHEMY_DATABASE_URL) async_session_maker =…
Homunculus Reticulli
  • 65,167
  • 81
  • 216
  • 341
0
votes
0 answers

Google oauth with fastapi-users procedure

I have the first steps working for fastapi-users==12.0.0 with Google OAuth but I don't know what to do with the access_token once I get it from /auth/google/callback. The fastapi logs show User has registered and a new row is added into…
Jaime Salazar
  • 349
  • 1
  • 2
  • 11
0
votes
0 answers

How to use fastapi-users with google oauth (from official docs full example)

I've copied the full sqlalchemy example from the fastapi-users docs with postgresql+asyncpg and I have something working, but I'm not sure if I'm using it correctly with Google. In the swagger UI I am able to use the Authorize form successfully and…
Jaime Salazar
  • 349
  • 1
  • 2
  • 11
0
votes
0 answers

how to do rollback in fastapi

i am trying to save 2 record in to database, in try block i have saved those two records : session.add(rec_1) await session.commit() await session.refresh(rec_1) i need rec_1 id, so i have saved and accessed in rec_2 session.add(rec_2) await…
kumar
  • 1
  • 1
0
votes
0 answers

How to connect alembic to sqlalchemy.orm.DeclarativeBase models?

I am new to FastAPI. I am currently studying FastAPI Users https://fastapi-users.github.io/fastapi-users/10.4/configuration/databases/sqlalchemy/ My question is: How can I migrate the "User" model using alembic, given that I already have models of…
0
votes
0 answers

FastAPI imports from an not running project into a manually used script to create user?

iam trying to create a new user via fastapi-users. I used this code which worked fine in the app.py with a running project: import contextlib from app.databases.user import get_async_session, get_user_db from app.schemas.schemas import…
Ano Nymous
  • 19
  • 4
0
votes
1 answer

How to change description of a include_router?

im trying to pass a new description to the include_router, but it doesn`t accept [description="description"]. Below you see the selfdefined working route with a custom description. from fastapi import Depends from sqlalchemy import select from…
Ano Nymous
  • 19
  • 4
0
votes
1 answer

How To set edit / delete permissions for the creator only in FAST API

i want to set up edit/delete permission for creator only. The main problem is in Frontend any user can update and delete without creator permission. I tried uuid for not guessing the id value. But the problem is still there. def…
1
2