This repository demonstrates how to implement JWT token refresh functionality using the Fetch API with a custom interceptor. It's a companion project for the YouTube tutorial on handling access and refresh tokens in web applications.
Tutorial Video: Watch on YouTube
- Backend: Django REST Framework with Simple JWT
- Frontend: React with React Router
- Authentication: JWT (JSON Web Tokens)
Before you begin, ensure you have the following installed:
- Python 3.x
- Node.js and npm
- Git
Clone the repository:
git clone https://github.com/dennisivy/refresh-token-interval
cd refresh-token-interval-
Navigate to the backend directory:
cd backend -
Install Python dependencies:
pip install -r requirements.txt
-
Run database migrations:
python manage.py migrate
-
Create a superuser account:
python manage.py createsuperuser
-
Start the Django development server:
python manage.py runserver
The backend will be running at http://localhost:8000
-
Navigate to the frontend directory (from the project root):
cd frontend -
Install Node.js dependencies:
npm install
-
Start the React development server:
npm start
The frontend will be running at http://localhost:3000
- Make sure both the backend and frontend servers are running
- Open your browser and navigate to
http://localhost:3000 - Log in with the superuser credentials you created
- The application will automatically handle token refresh using the custom interceptor