Run on 147.45.162.232 with Django and Browsable API.
- /api/register/
- /api/login/
- /api/refresh/
- /api/me/
- /api-doc/
Admin zone: /admin/
Superuser: [email protected]
123Qwe123
================================ Description =========================
- REST API for a user authentication and authorization system using Django and Django REST Framework.
- The system supports user registration, authentication, token refresh, logout, and allow users to retrieve and update their personal information.
- Authentication utilizes Access and Refresh tokens.
- Refresh Token – A UUID stored in the database, issued for 30 days by default.
- Access Token – A JSON Web Token with a default lifespan of 30 seconds.
- Used the django-constance module for managing the lifetimes of Access and Refresh tokens.
- Superuser can manage with lifetime parameters of tokens in admin area (ip/admin).
- Clients may request an Access Token refresh at any time, for instance, upon Access Token expiry by providing a valid Refresh Token.
- In this case, the service returns a new valid pair of Access and Refresh Tokens, resetting their lifespans.
- Provide a browsable API with endpoint documentation.
============================= Requests Examples ====================
User Registration
Endpoint: /api/register/
Method: POST
Body: {"password": "password", "email": "[email protected]"}
Response: {"id": 1, "email": "[email protected]"}
Authentication (Obtaining Access and Refresh Token)
Endpoint: /api/login/
Method: POST
Body: {"email": "[email protected]", "password": "password"}
Response: {"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxMjMsImV4cCI6MTcxMjE0NTk0NiwiaWF0IjoxNzEyMTQ1OTE2fQ.KX6LM66tC3p3bUCdkWRQkPvariP8tzUfWd8Z13akCPY", "refresh_token": "d952527b-caef-452c-8c93-1100214f82e5"}
Access Token Refresh
Endpoint: /api/refresh/
Method: POST
Body: {"refresh_token": "d952527b-caef-452c-8c93-1100214f82e5"}
Response: {"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxMjMsInVzZXJuYW1lIjoiZXhhbXBsZVVzZXIiLCJleHAiOjE3MTIxNDYxNDd9.zKobBlRuOiJSxCmi-iYap1bejfnvK6M3qtnkT0ssDKA", "refresh_token": "eb0464c2-ed6e-4346-a709-042c33946154"}
Logout (Invalidating Refresh Token)
Endpoint: /api/logout/
Method: POST
Body: {"refresh_token": "eb0464c2-ed6e-4346-a709-042c33946154"}
Response: {"success": "User logged out."}
Retrieving Personal Information
Endpoint: /api/me/
Method: GET
Header: Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxMjMsInVzZXJuYW1lIjoiZXhhbXBsZVVzZXIiLCJleHAiOjE3MTIxNDYxNDd9.zKobBlRuOiJSxCmi-iYap1bejfnvK6M3qtnkT0ssDKA
Response: {"id": 1, "username": "", "email": "[email protected]"}
Updating Personal Information
Endpoint: /api/me/
Method: PUT
Header: Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxMjMsInVzZXJuYW1lIjoiZXhhbXBsZVVzZXIiLCJleHAiOjE3MTIxNDYxNDd9.zKobBlRuOiJSxCmi-iYap1bejfnvK6M3qtnkT0ssDKA
Body: {"username": "John Smith"}
Response: {"id": 1, "username": "John Smith", "email": "[email protected]"}