FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

codebythura/Refresh_Access_Token_Flow: ๐Ÿ” Access Token Refresh Example with Ktor Server and Flutter Client ยท GitHub

Latest commit

ย 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” Refresh Token Flow Example (Ktor Server + Flutter Client)

This repository demonstrates a complete working example of handling access token refreshing in a client-server architecture using:

  • Ktor as the backend server
  • Flutter as the mobile client app

๐Ÿ“Œ Features

  • ๐Ÿงพ JWT-based authentication with access and refresh tokens
  • โฑ Access token expires in 1 minute (for testing)
  • โ™ป๏ธ Refresh token expires in 2 minutes
  • ๐Ÿ”„ Automatic access token refresh when expired
  • ๐Ÿšช Forced logout when refresh token is also expired

๐Ÿ› ๏ธ Components

โœ… Server (Ktor)

  • Exposes endpoints for:

    • /auth/signup
    • /auth/login
    • /auth/refresh
    • /get_data?userId
  • Generates JWTs using HMAC

  • Stores refresh tokens and validates them during token refresh

๐Ÿ“ฑ Client (Flutter)

  • Stores tokens securely using flutter_secure_storage

  • Intercepts HTTP 401 errors

    • Automatically retries the original request after refreshing the token
    • If refresh token is also expired, logs the user out
  • Uses state management BLoC to manage state

๐Ÿš€ How to Run

  1. Start the Ktor Server
cd ktor-server
./gradlew run
  1. Run the Flutter App
cd flutter-client
flutter run

About

๐Ÿ” Access Token Refresh Example with Ktor Server and Flutter Client

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages


Back | FazBrowse Home | New Git URL