OAuth 암시적 인증을 사용하여 Twitch.tv API에 연결하기 위한 래퍼를 제공하는 순수 Dart 패키지입니다. Twitch 서비스와의 통합을 간소화하여 개발자가 사용자를 인증하고 스트리밍, 채널, 사용자 정보 등의 공개 데이터에 접근할 수 있도록 합니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼을 지원하며, 크로스플랫폼 애플리케이션에 적합합니다. 사용 편의성을 고려해 OAuth 흐름의 복잡성을 처리하면서도 안전성과 Twitch의 현재 인증 기준과의 호환성을 유지합니다.
사용 사례
Twitch 로그인 기능 통합
실시간 스트리밍 데이터 가져오는 중
사용자 및 채널 정보에 액세스
Twitch 기반 소셜 앱 구축
스트리머를 위한 대시보드 만들기
주요 기능
OAuth 암시적 인증
크로스 플랫폼 지원
순수한 다트 구현
간단한 API 인터페이스
보안 토큰 처리
적합한 대상
Twitch 통합이 필요한 Flutter 앱
스트림 모니터링 도구
Twitch 커뮤니티 플랫폼
Twitch 콘텐츠용 개발 도구
다중 플랫폼 애플리케이션
고려 사항
올바른 트위치 앱 등록이 필요합니다
OAuth 암시적 흐름에 한정
Twitch API 속도 제한에 따라 다름
리프레시 토큰을 주의 깊게 처리해야 합니다
서버 측 작업에 적합하지 않습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
twitch_api
A wrapper in pure Dart to connect to Twitch.tv using OAuth implicit authentication.
NOTE: This package is in its early stage, please be patient until more methods are implemented or do not hesitate to open a merge request if you added support for an endpoint. Currently I do not have a roadmap of the endpoint I am going to add in priority so do not hesitate to open an issue to make suggestions depending of your needs.
To use this package you will need to register an application on the Twitch developer console to get a client ID.
After registering your application you will need to instantiate the TwitchClient class from the package with your clientId and your redirectUri .
import'package:twitch_api/twitch_api.dart';
final _twitchClient = TwitchClient(
clientId: clientId,
redirectUri: redirectUri,
);
Now that you have initialized the client the last step before using the method will be to manage the first connection with your twitch account and initialize the token you will receive. You can find a complete example of an implementation using the package flutter_webview_plugin.
const clientId = "<YOUR_CLIENT_ID>";
const redirectUri = "<YOUR_REDIRECT_URL>"; // ex: "http://localhost/"final _twitchClient = TwitchClient(
clientId: clientId,
redirectUri: redirectUri,
);
final _flutterWebviewPlugin = FlutterWebviewPlugin();
// First authentication through a webviewFuture<TwitchToken> _openConnectionPage({
List<TwitchApiScope> scopes = const [],
}) {
// Listen for url changes to detect redirection on our redirectUri.
_flutterWebviewPlugin.onUrlChanged.listen((url) {
if (url.startsWith(_twitchClient.redirectUri)) {
// After you got to your redirectUri you can initialize the token.
_twitchClient.initializeToken(TwitchToken.fromUrl(url));
// Close the webview
_flutterWebviewPlugin.close();
}
});
// When the webview is closed pop the current route.
_flutterWebviewPlugin.onDestroy.listen((_) => Navigator.pop(context));
// Get authorization URL for the connection with the webview.final _url = _twitchClient.authorizeUri(scopes);
returnNavigator.push(
context,
MaterialPageRoute(
builder: (context) => WebViewPage(_url.toString()),
),
).then((_) => _twitchClient.twitchHttpClient.validateToken());
}
Now you are ready to use the methods implemented in Supported Endpoints section.
Supported Endpoints
Ads
[x] Start Commercial
Analytics
[x] Get Extension Analytics
[x] Get Game Analytics (Documentation in progress)