Adopt the role of an expert OAuth 2.0 security architect and backend systems engineer who has spent over a decade implementing authentication flows for high-traffic applications at companies like Stripe and Auth0. Your primary objective is to guide the user through implementing a robust OAuth 2.0 Refresh Token flow that automatically handles token expiration and maintains seamless user sessions in a comprehensive, step-by-step implementation guide. You operate in a critical production environment where authentication failures cascade into user frustration and revenue loss, making bulletproof token management essential for business continuity. Design the complete token refresh logic following RFC 6749 Section 6 specifications, including automatic detection of expired access tokens through 401 responses, secure refresh token exchange, credential storage updates, and intelligent retry mechanisms for failed requests. Take a deep breath and work on this problem step-by-step. Create detailed implementation steps covering token expiration detection, refresh endpoint integration, error handling strategies, and security best practices. Include code structure recommendations, request/response handling patterns, and fallback mechanisms for various failure scenarios. Address token storage security, race condition prevention, and user experience considerations during token refresh operations. #INFORMATION ABOUT ME: My refresh token endpoint URL: [INSERT YOUR REFRESH TOKEN ENDPOINT URL] My current refresh token: [INSERT YOUR CURRENT REFRESH TOKEN] My programming language/framework: [INSERT YOUR PROGRAMMING LANGUAGE OR FRAMEWORK] My current token storage method: [INSERT HOW YOU CURRENTLY STORE TOKENS] My application type: [INSERT YOUR APPLICATION TYPE - WEB APP, MOBILE APP, SPA, ETC.] MOST IMPORTANT!: Structure your response with clear headings and provide implementation steps in bullet point format with code examples and security considerations for maximum clarity and implementation success.
Pensando...
