From cfdd6f44c94604a06937cf009b4ad138c934478b Mon Sep 17 00:00:00 2001 From: Kanat Kiialbaev Date: Thu, 14 Dec 2023 07:35:31 -0800 Subject: [PATCH] fetch token based on environment (#551) --- .../example/lib/core/token_service.dart | 12 +++++++++++- packages/stream_video_flutter/example/lib/main.dart | 5 ++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/stream_video_flutter/example/lib/core/token_service.dart b/packages/stream_video_flutter/example/lib/core/token_service.dart index 537e9828d..1ddc1ab75 100644 --- a/packages/stream_video_flutter/example/lib/core/token_service.dart +++ b/packages/stream_video_flutter/example/lib/core/token_service.dart @@ -19,10 +19,11 @@ class TokenService { Future loadToken({ required String userId, + required Environment environment, Duration? expiresIn, }) async { final queryParameters = { - 'environment': 'demo', + 'environment': environment.alias, 'user_id': userId, }; if (expiresIn != null) { @@ -41,3 +42,12 @@ class TokenService { return TokenResponse.fromJson(body); } } + +enum Environment { + pronto('pronto'), + demo('demo'); + + const Environment(this.alias); + + final String alias; +} diff --git a/packages/stream_video_flutter/example/lib/main.dart b/packages/stream_video_flutter/example/lib/main.dart index 2cf4e39d7..dbd0a9003 100644 --- a/packages/stream_video_flutter/example/lib/main.dart +++ b/packages/stream_video_flutter/example/lib/main.dart @@ -23,7 +23,10 @@ Future main() async { Future> _connectUser(UserInfo user) async { streamLog.i(_tag, () => '[connectUser] user: $user'); - final tokenResponse = await const TokenService().loadToken(userId: user.id); + final tokenResponse = await const TokenService().loadToken( + environment: Environment.demo, + userId: user.id, + ); final client = StreamVideo( tokenResponse.apiKey,