mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
2.4 KiB
2.4 KiB
description
| description |
|---|
| Controller for managing token refresh operations, allowing users to refresh their access tokens using a valid refresh token. |
RefreshController
Controller Description
- Route:
api/auth/token - Authorize: Allows anonymous access (
[AllowAnonymous]).
Endpoints
Refresh
- Description: Refreshes an access token using a provided refresh token and returns a new access token and refresh token pair.
- Route:
[POST] api/auth/token/refresh - HTTP Method:
POST - Request:
-
Content-Type:
application/json -
Request Body:
RefreshTokenRequestobject with the following structure:{ "refreshToken": "string" }
-
- Responses:
-
200 OK: Returns a new access token and refresh token upon successful refresh.
{ "accessToken": "string", "refreshToken": "string" } -
400 Bad Request: If model validation fails or the refresh token is empty.
"Refresh token cant be empty." -
401 Unauthorized: If the refresh token is invalid or authorization fails.
"Invalid refresh token" -
500 Internal Server Error: Indicates an unexpected error.
"An unexpected error occurred."
-
Data Models
RefreshTokenRequest
-
Description: Model for refresh token request data.
-
Structure:
{ "refreshToken": "string" }
RefreshTokenResponse
-
Description: Model for refresh token response data.
-
Structure:
{ "accessToken": "string", "refreshToken": "string" }
Error Handling
- Invalid User ID: Not applicable (handled by session service).
- Invalid Operations: Returns
400 Bad Requestif the refresh token is empty or invalid. - Unauthorized Access: Returns
401 Unauthorizedif the refresh token fails authorization. - Unexpected Errors: General exceptions are caught, logged, and returned as
500 Internal Server Error.
Logging
- Logs warnings for invalid or failed refresh token attempts.
- Logs errors for unexpected exceptions during token refresh.