Skip to content

Commit

Permalink
fetch token based on environment (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
kanat authored Dec 14, 2023
1 parent 577bccd commit cfdd6f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ class TokenService {

Future<TokenResponse> loadToken({
required String userId,
required Environment environment,
Duration? expiresIn,
}) async {
final queryParameters = <String, dynamic>{
'environment': 'demo',
'environment': environment.alias,
'user_id': userId,
};
if (expiresIn != null) {
Expand All @@ -41,3 +42,12 @@ class TokenService {
return TokenResponse.fromJson(body);
}
}

enum Environment {
pronto('pronto'),
demo('demo');

const Environment(this.alias);

final String alias;
}
5 changes: 4 additions & 1 deletion packages/stream_video_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ Future<void> main() async {
Future<Result<None>> _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,
Expand Down

0 comments on commit cfdd6f4

Please sign in to comment.