Skip to content

Auth API's

kwai.api.v1.auth.endpoints.login

Module that implements all APIs for login.

kwai.api.v1.auth.endpoints.login.login(settings=deps.depends(Settings), db=deps.depends(Database), form_data=Depends()) async

Login a user.

The response is a TokenSchema.

Note

This request expects a form (application/x-www-form-urlencoded).

Parameters:

Name Type Description Default
settings

Settings dependency

deps.depends(Settings)
db

Database dependency

deps.depends(Database)
form_data OAuth2PasswordRequestForm

Form data that contains the username and password

Depends()

kwai.api.v1.auth.endpoints.login.logout(settings=deps.depends(Settings), db=deps.depends(Database), user=Depends(get_current_user), refresh_token=Form()) async

Log out the current user.

A user is logged out by revoking the refresh token. The associated access token will also be revoked.

Parameters:

Name Type Description Default
settings

Settings dependency

deps.depends(Settings)
db Database

Database dependency

deps.depends(Database)
user UserEntity

The currently logged-in user

Depends(get_current_user)
refresh_token str

The active refresh token of the user

Form()

Returns:

Type Description

Http code 200 on success, 401 when the user is not logged in,

404 when the refresh token is not found.

kwai.api.v1.auth.endpoints.login.recover_user(email=Form(), db=deps.depends(Database), bus=deps.depends(Bus)) async

Start a recover password flow for the given email address.

A mail with a unique id will be sent using the message bus.

Note

To avoid leaking information, this api will always respond with 200

Parameters:

Name Type Description Default
email(str)

The email of the user that wants to reset the password.

required
db(Database)

Database dependency

required
bus(Bus)

A message bus used to publish the event

required

kwai.api.v1.auth.endpoints.login.renew_access_token(settings=deps.depends(Settings), db=deps.depends(Database), refresh_token=Form()) async

Refresh the access token.

Parameters:

Name Type Description Default
settings(Settings)

Settings dependency

required
db(Database)

Database dependency

required
refresh_token(str)

The active refresh token of the user

required

Returns:

Name Type Description
TokenSchema

On success a new TokenSchema is returned.

kwai.api.v1.auth.endpoints.login.reset_password(uuid=Form(), password=Form(), db=deps.depends(Database)) async

Reset the password of the user.

Parameters:

Name Type Description Default
uuid(str)

The unique id of the password recovery.

required
password(str)

The new password

required
db(Database)

Database dependency

required

Returns:

Type Description

Http code 200 on success, 404 when the unique is invalid, 422 when the

request can't be processed, 403 when the request is forbidden.

Auth Responses

kwai.api.v1.auth.endpoints.login.TokenSchema

Bases: BaseModel

The response schema for an access/refresh token.

Attributes:

Name Type Description
access_token str
refresh_token str
expiration str

Timestamp in format YYYY-MM-DD HH:MM:SS