Guest Users

Last Edit: Sep 22 2020

Guest sessions can be created client-side and do not require any server-side authentication.

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 setUser.


await client.setGuestUser({ id: 'tommaso' });
                    

client.getGuestToken(userId, userName).enqueue(result -> {
    User user = result.data().component1();
    String token = result.data().component2();

    client.setUser(user, token, null);

    return Unit.INSTANCE;
});
                    

let userExtraData = UserExtraData(name: "Bender", avatarURL: URL(string: "https://bit.ly/321RmWb")!)
let user = User(id: "bender", extraData: userExtraData)
// Setup the current user and guest token.
Client.shared.setGuestUser(user: user)
                    

val userId = "user-id"
val userName = "bender"
client.getGuestToken(userId, userName).enqueue {
    val token = it.data().token
    val user = it.data().user

    client.setUser(user, token)
}
                    
The user object schema is the same as the one described in the Setting the user portion of the docs.