Skip to content

user profile 401 Unauthorized #1327

Answered by frankie567
lifengmds asked this question in Q&A
Discussion options

You must be logged in to vote

You defined your model with an int ID:

class Users(SQLModelBaseUserDB, table=True):
    __tablename__ = "user"
    __table_args__ = {'extend_existing': True}
    id: Optional[int] = Field(default=None, primary_key=True, nullable=False, title="ID")

However, you used the UUIDIDMixin in the user manager:

class UserManager(UUIDIDMixin, BaseUserManager[User, id]):

You need to be consistent on the ID type. If you wish to keep an integer ID, UserManager should look like this:

class UserManager(IntegerIDMixin, BaseUserManager[User, int]):

Ref: https://fastapi-users.github.io/fastapi-users/12.1/configuration/user-manager/#the-id-parser-mixin

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@lifengmds
Comment options

Answer selected by lifengmds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
3 participants
Converted from issue

This discussion was converted from issue #1326 on December 28, 2023 07:22.