Guest Users

LAST EDIT Apr 08 2021

Guest sessions can be created client-side and do not require any server-side authentication. Support and livestreams are common use cases for guests users because really often you want a visitor to be able to use chat on your application without (or before) they have a regular user account.

Guest users are not available to application using multi-tenancy (teams).

Unlike anonymous users, guest users are counted towards your MAU usage.

Guest users have a limited set of permissions. You can read more about how to configure permissions here. You can create a guest user session by using setGuestUser instead of connectUser.

1
await client.setGuestUser({ id: 'tommaso' });
1
client.connectGuestUser("bender", "Bender").enqueue(result -> { /* ... */ });
1
2
3
4
5
6
7
8
9
10
import StreamChat 
 
/// 1: Create a guest token provider. 
let tokenProvider = TokenProvider.guest(userId: "john-doe") 
 
/// 2: Create a `ChatClientConfig` with the API key. 
let config = ChatClientConfig(apiKeyString: "YOUR_API_KEY") 
 
/// 3: Create a `ChatClient` instance with the config and the token provider. 
chatClient = ChatClient(config: config, tokenProvider: tokenProvider)
1
client.connectGuestUser(userId = "bender", username = "Bender").enqueue { /*... */ }
1
await client.connectGuestUser(User('id': 'tommaso'));
The user object schema is the same as the one described in the Setting the user portion of the docs.