implement-auth-token-flow

Implement Bearer token authentication flows for Flutter apps with Dio interceptors.

Updated Apr 1, 2026
One-click install
npx skills add https://github.com/andrelucassvt/CleanMacForDevsWeb --skill implement-auth-token-flow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: implement-auth-token-flow
Source: https://github.com/andrelucassvt/CleanMacForDevsWeb/tree/main/.agents/skills/implement-auth-token-flow
Command: npx skills add https://github.com/andrelucassvt/CleanMacForDevsWeb --skill implement-auth-token-flow

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Implements the complete Bearer token authentication flow for Flutter apps, covering login, token storage, automatic token injection via interceptors, proactive token refresh, and redirect to login on 401 (expired token).

Core Features & Use Cases

  • End-to-end authentication workflow for Flutter with login, token persistence, and automatic Bearer header injection.
  • Proactive token refresh before expiry and seamless retry of authenticated requests.
  • DI-driven architecture and clear separation of concerns (AuthService, Repository, DataSources, Cubits) enabling easy maintenance and testing.

Quick Start

Configure the DI and wiring so the app can login, persist tokens, auto-inject Bearer tokens, refresh before expiry, and redirect to login on 401.

Frequently Asked Questions about implement-auth-token-flow

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a Bearer token authentication flow in Flutter with Dio?

You can implement Bearer token authentication by using interceptors to inject tokens, storing access and refresh tokens, proactively refreshing tokens before expiry, and redirecting to login on 401 responses.

What is the best way to handle automatic token refresh in Flutter?

The best way to handle automatic token refresh is to proactively refresh tokens before their expiration time and seamlessly retry authenticated requests using a dedicated Dio instance for the refresh process.

How do I redirect users to login when a token expires in a Flutter app?

You redirect users to login when a token expires by configuring interceptors to detect 401 responses, trigger a token refresh or clear the session, and navigate the user back to the login flow.

Can I use this Bearer token flow with a Dependency Injection setup in Flutter?

Yes, this Bearer token flow uses a DI-driven architecture with a defined wiring order: StorageService, AuthService, Dio, HttpService, DataSources, Repositories, and Cubits to ensure clear separation of concerns.

Why do I need a dedicated Dio instance for token refresh in Flutter?

You need a dedicated Dio instance for token refresh to prevent infinite loops if the refresh endpoint itself returns a 401, ensuring the refresh request bypasses the auth interceptors.

Flutter Dio 401 interceptor not working, what are the limitations?

If your Dio 401 interceptor is not working, verify your DI order and ensure your interceptor correctly pauses the request queue, attempts a token refresh, and resumes the request with the new Bearer header.