Web DevelopmentAdvanced 4 to 6 hours

OAuth, Route Guards, & Token Refresh

Build a robust authentication architecture that survives edge cases.

The Scenario

You are the lead frontend engineer for a financial dashboard. Security is paramount. Users log in via an external OAuth provider. The access token expires every 15 minutes, and a silent refresh token must be used to keep them logged in. Furthermore, unauthenticated users must be redirected away from `/dashboard`.

The Brief

Design the authentication architecture. You do not need to build the UI. Write the logic for three critical pieces: 1) A Higher-Order Component (HOC) or wrapper that protects private routes. 2) An Axios interceptor (or fetch wrapper) that automatically catches 401 errors, uses a refresh token to get a new access token, and retries the failed request. 3) The initialization logic that checks if a user is already logged in when they refresh the page.

Deliverables

  • The Route Guard implementation (e.g., `ProtectedRoute.tsx`)
  • The Axios interceptor or custom fetch wrapper handling the token refresh logic
  • A short architecture note explaining how you prevent multiple failed requests from triggering multiple refresh calls simultaneously

Submission Guidance

This task tests your ability to handle complex asynchronous control flows. The interceptor logic is notoriously tricky - walk through your solution carefully.

Submit Your Work

Your submission is graded against the rubric on the right. If you pass, you get a public Badge URL you can share on LinkedIn. There is no draft save, so work offline first and paste your finished response here.

This appears on your public Badge.

0/20000 charactersMarkdown supported

One per line or comma separated. Up to 5 links.

By submitting, you agree your submission text, name, and evaluation will appear on a public Badge URL.