Token’ı kendi sunucunuzda üretin
Katılım token’ı üretmenin desteklenen yolu — ve düştüğünde tek oturum zorlamasını sessizce kapatan tek alan.
Neden sunucuda?
Sunucu gizli anahtarınız uygulamaya asla girmez. APK içine konan her anahtar çıkarılabilir ve herhangi bir kullanıcı taklit edilebilir.
Cihaz bilgilerini iletin
Sunucunuz cihazı göremez. Uygulama bu değerleri sunucunuza yollar, sunucunuz aynı istekte bize iletir.
Arıza sessizdir
device_id olmadan denetim hata ve log olmadan erken döner. Token başarılı olur, koruma kapalı kalır.
Varsayım değil, ölçüm
Üç saatlik gerçek katılımda: sunucuda üretilen token’lar 3.224 katılım — %100’ü cihaz kimliği olmadan. Kit’te üretilenler 1.641 katılım — %0.
Token isteği alanları
Başlıkta sunucu gizli anahtarıyla /api/v1/token adresine POST edin.
| Alan | Düzey | Anlamı |
|---|---|---|
user_idstring | Zorunlu | Who the token is for. Your own user id. (Previously `identity` — still accepted.) |
room_idstring | Zorunlu | Which room they are joining. (Previously `room_name` — still accepted.) |
device_idstring | Önerilen | A stable id for the PHYSICAL DEVICE — not the user, and not the session. This is what enforces one account on one device: when the same user_id joins from a different device_id, the previous device is messaged and removed. Omit it and that enforcement silently does nothing: the check returns early, logs nothing, and the old device stays signed in. |
device_modelstring | Önerilen | e.g. SM-A175F. Feeds per-handset quality analysis — which models have audio or video trouble. |
osstring | Önerilen | android | ios. |
os_versionstring | Önerilen | e.g. 14. |
app_versionstring | Önerilen | Your app's version, so a regression can be traced to a release. |
display_namestring | İsteğe bağlı | Shown to other participants. Omit it and the name stays empty — we never substitute the user id for it. |
rolestring | İsteğe bağlı | Only honoured from a server-signed request, and only while your project still carries the client-asserted-role exception. The supported path is PUT /rooms/:room/participants/:id/role. |
typestring | İsteğe bağlı | audio_room | live_stream. Legacy kits send `service` (+ `kind`) instead and the type is derived. |
Sunucunuzda
Gizli anahtar yalnızca burada durur. İşaretli alanlar uygulamadan gelir — sunucunuz bunları kendi başına bilemez.
// Your backend — the app never sees the server secret.
const res = await fetch("https://engine.udt-stream.com/api/v1/token", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-App-Secret": process.env.UTD_SERVER_SECRET, // never ship this in the app
},
body: JSON.stringify({
user_id: currentUser.id,
room_id: roomId,
// 🔴 Forwarded FROM THE APP. Your server cannot know these on its own,
// and without device_id one-account-one-device stops working for your users.
device_id: body.device_id,
device_model: body.device_model,
os: body.os,
os_version: body.os_version,
app_version: body.app_version,
}),
});Uygulamanızda
Cihaz bilgilerini kendi sunucunuza gönderin, o iletsin. Cihaz kimliği uygulama yeniden başlasa da aynı kalmalı.
// Your app — send the device facts to YOUR backend, which forwards them to us.
final deviceId = await MyDeviceIdentity.stableId(); // persisted, survives app restarts
await myApi.post("/rooms/$roomId/token", body: {
"device_id": deviceId,
"device_model": deviceInfo.model,
"os": Platform.isAndroid ? "android" : "ios",
"os_version": deviceInfo.version,
"app_version": packageInfo.version,
});Ret kodları (403)
Her ret bir code taşır. Kodu okuyun — “odadan çıkarıldınız” mesajını yalnızca ilkinde gösterin.
| Kod | Anlamı | Ne yapmalı |
|---|---|---|
user_banned | This user is banned from this room. | Show them they were removed. This is the ONLY code that should produce that message. |
room_type_disabled | The project does not have this room type enabled. | A configuration problem, not a user problem. Never show a removal notice. |
streaming_disabled | The streaming service is not enabled for this project. | Same — configuration, not the user. |
appkey_identity_mint_disabled | You tried to mint an identity-bearing token with the publishable app_key. | Mint from your backend with the server secret instead. This is the path this page describes. |
Kimlik doğrulama modları
Motor her katılımda modu kaydeder; böylece gerçekte hangi yolda olduğunuzu doğrulayabilirsiniz.
secret / signature / bearerYour backend, authenticated with your server secret. The recommended path.
app_keyThe device, using the publishable app key. The legacy path — being closed.
UTD ile inşa etmeye hazır mısınız?
Hesabınızı oluşturun, ana cüzdanınızı fonlayın ve ihtiyacınız olan hizmetleri açın.