Skip to content

TokenFlow

GitHub License Documentation

Important Notice

This library may violate GitHub Copilot's Terms of Service. Using this library to access GitHub Copilot without proper authorization may result in account suspension or termination. This project is for educational and research purposes only. Use at your own risk and ensure you have appropriate authorization before using this library.

TokenFlow is a multi-language OAuth2 Device Flow implementation supporting GitHub Copilot and Hyper services.

Features

GitHub Copilot Integration

  • ✅ OAuth2 Device Authorization Flow (RFC 8628)
  • ✅ Token caching from official Copilot client
  • ✅ Custom HTTP client with X-Initiator header injection
  • ✅ Automatic token refresh

Hyper Integration

  • ✅ Device authorization flow
  • ✅ Token exchange
  • ✅ Token introspection (RFC 7662)
  • ✅ Configurable base URL via environment variable

Token Management

  • ✅ Unified token structure across all implementations
  • ✅ Automatic expiration calculation
  • ✅ 10% buffer for token refresh
  • ✅ JSON serialization support

Language Implementations

TokenFlow is available in three languages:

go get github.com/lichman0405/tokenflow/go

Go Documentation

pip install tokenflow

Python Documentation

npm install tokenflow

TypeScript Documentation

Security

All implementations include:

  • ⏱️ 30-second HTTP request timeouts
  • 📏 1MB response size limits
  • 🔄 Token refresh before expiration

Author

Shibo Li
📧 shadow.li981@gmail.com

References

This project is inspired by:

License

MIT License - see LICENSE for details.