Skip to content

Commit cfdd6f4

Browse files
authored
fetch token based on environment (#551)
1 parent 577bccd commit cfdd6f4

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/stream_video_flutter/example/lib/core/token_service.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ class TokenService {
1919

2020
Future<TokenResponse> loadToken({
2121
required String userId,
22+
required Environment environment,
2223
Duration? expiresIn,
2324
}) async {
2425
final queryParameters = <String, dynamic>{
25-
'environment': 'demo',
26+
'environment': environment.alias,
2627
'user_id': userId,
2728
};
2829
if (expiresIn != null) {
@@ -41,3 +42,12 @@ class TokenService {
4142
return TokenResponse.fromJson(body);
4243
}
4344
}
45+
46+
enum Environment {
47+
pronto('pronto'),
48+
demo('demo');
49+
50+
const Environment(this.alias);
51+
52+
final String alias;
53+
}

packages/stream_video_flutter/example/lib/main.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ Future<void> main() async {
2323
Future<Result<None>> _connectUser(UserInfo user) async {
2424
streamLog.i(_tag, () => '[connectUser] user: $user');
2525

26-
final tokenResponse = await const TokenService().loadToken(userId: user.id);
26+
final tokenResponse = await const TokenService().loadToken(
27+
environment: Environment.demo,
28+
userId: user.id,
29+
);
2730

2831
final client = StreamVideo(
2932
tokenResponse.apiKey,

0 commit comments

Comments
 (0)