Authentication in Sceyt Chat is entirely token-based. Your backend issues a short-lived JSON Web Token (JWT) signed with your Sceyt application credentials, your Android app requests that token at login time, and then passes it directly toDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sceyt/sceyt-chat-android-uikit/llms.txt
Use this file to discover all available pages before exploring further.
SceytChatUIKit.connect(). The SDK never stores credentials — it only holds the token in memory for the duration of the session. This design keeps your Sceyt app secret safely on your server and makes it straightforward to rotate tokens as they expire.
How tokens work
User logs in to your backend
Your server authenticates the user by whatever mechanism you choose (password, OAuth, SSO, etc.) and then calls the Sceyt REST API to issue a signed JWT for that user.
Backend returns the token to your app
The JWT is returned as part of your own login response. Your app stores it in memory (or in an encrypted store if persistence across cold starts is required).
App calls SceytChatUIKit.connect()
Pass the token to the UIKit. The SDK opens a WebSocket, presents the token, and the Sceyt server validates it and begins the session.
Connecting a user
After your login flow delivers a token, callconnect():
ConnectionEventManager.onChangedConnectStatusFlow to react once the connection is live:
Reading the current user
Once connected, the UIKit exposes the authenticated user’s identity through two properties onSceytChatUIKit:
null when no user is connected. Check for null before accessing them outside of a connected session.
Handling token expiry
Tokens expire. If your app does not supply a fresh token in time, the WebSocket connection is dropped and the user is effectively disconnected. The SDK surfaces two distinct warning stages throughSharedFlow properties on SceytChatUIFacade:
| Flow | When it emits | Recommended action |
|---|---|---|
onTokenWillExpire | Shortly before the token expires | Proactively fetch a new token and call updateToken() |
onTokenExpired | The moment the token has expired | Urgently fetch a new token and call updateToken() to reconnect |
ViewModel or your Application’s CoroutineScope:
Implementing ChatTokenProvider for automatic refresh
The cleanest way to handle token renewal is to implement theChatTokenProvider functional interface and assign it to SceytChatUIKit.chatTokenProvider. The SDK calls provideToken() automatically whenever it needs a fresh token — you no longer need to manually collect the expiry flows.
The interface
provideToken() is a suspend function, so you can freely call any suspending API (Retrofit, Ktor, etc.) inside it. Return the new token as a String, or return null if token retrieval fails (the SDK will treat this as a failed refresh).
Implementation example
Registering the provider
Set the provider once afterSceytChatUIKit.initialize() — typically alongside your other UIKit customizations in Application.onCreate():
Updating the token manually
If you prefer to manage the refresh lifecycle yourself — or if you need to push a new token at a moment of your choosing — callSceytChatUIFacade.updateToken() directly:
The fresh JWT to deliver to the server.
Optional callback invoked on the result of the server-side token validation.
success = true means the connection is live again with the new token.Logging out
When the user signs out, callSceytChatUIKit.logOut(). This clears all cached data, unregisters the device’s push token from Sceyt’s servers, and closes the WebSocket:
logOut() returns, SceytChatUIKit.currentUserId and SceytChatUIKit.currentUser will both be null, and no data remains on disk.