اپنے بیک اینڈ سے ٹوکن جاری کرنا
جوائن ٹوکن جاری کرنے کا معتمد طریقہ — اور وہ ایک فیلڈ جس کے گرتے ہی سنگل سیشن کا نفاذ خاموشی سے بند ہو جاتا ہے۔
بیک اینڈ سے کیوں؟
آپ کا سرور سیکرٹ کبھی ایپ میں نہیں جانا چاہیے۔ APK میں شامل کوئی بھی کلید نکالی جا سکتی ہے اور کسی کی بھی شناخت اختیار کی جا سکتی ہے۔
ڈیوائس کی معلومات آگے بھیجیں
آپ کا سرور ڈیوائس نہیں دیکھ سکتا۔ ایپ یہ قدریں آپ کے سرور کو بھیجے، اور سرور اسی درخواست میں ہمیں منتقل کرے۔
خرابی خاموش ہے
device_id کے بغیر جانچ بغیر خطا اور بغیر لاگ کے جلد واپس آ جاتی ہے۔ ٹوکن کامیاب ہوتا ہے اور تحفظ بند رہتا ہے۔
ماپا گیا، فرض نہیں کیا گیا
تین گھنٹے کے حقیقی جوائنز پر: بیک اینڈ سے جاری ٹوکن ۳٬۲۲۴ جوائن — ۱۰۰٪ بغیر ڈیوائس آئی ڈی۔ کِٹ سے جاری ٹوکن ۱٬۶۴۱ جوائن — صفر٪۔
ٹوکن درخواست کے فیلڈز
ہیڈر میں سرور سیکرٹ کے ساتھ /api/v1/token پر POST کریں۔
| فیلڈ | درجہ | مطلب |
|---|---|---|
user_idstring | لازمی | Who the token is for. Your own user id. (Previously `identity` — still accepted.) |
room_idstring | لازمی | Which room they are joining. (Previously `room_name` — still accepted.) |
device_idstring | تجویز کردہ | 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 | تجویز کردہ | e.g. SM-A175F. Feeds per-handset quality analysis — which models have audio or video trouble. |
osstring | تجویز کردہ | android | ios. |
os_versionstring | تجویز کردہ | e.g. 14. |
app_versionstring | تجویز کردہ | Your app's version, so a regression can be traced to a release. |
display_namestring | اختیاری | Shown to other participants. Omit it and the name stays empty — we never substitute the user id for it. |
rolestring | اختیاری | 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 | اختیاری | audio_room | live_stream. Legacy kits send `service` (+ `kind`) instead and the type is derived. |
آپ کے سرور پر
سیکرٹ صرف یہیں رہتا ہے۔ نشان زدہ فیلڈز ایپ سے آتے ہیں — سرور خود سے انہیں نہیں جان سکتا۔
// 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,
}),
});آپ کی ایپ میں
ڈیوائس کی معلومات اپنے بیک اینڈ کو بھیجیں، وہ آگے منتقل کرے گا۔ ڈیوائس آئی ڈی ایپ دوبارہ چلنے پر بھی وہی رہنی چاہیے۔
// 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,
});انکار کے کوڈ (403)
ہر انکار کے ساتھ ایک code ہوتا ہے۔ کوڈ پڑھیں — "آپ کو نکال دیا گیا" صرف پہلے پر دکھائیں۔
| کوڈ | مطلب | کیا کریں |
|---|---|---|
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. |
تصدیق کے طریقے
انجن ہر جوائن پر طریقہ ریکارڈ کرتا ہے، تاکہ آپ جانچ سکیں کہ آپ حقیقتاً کس راستے پر ہیں۔
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 کے ساتھ تعمیر کے لیے تیار ہیں؟
اپنا اکاؤنٹ بنائیں، اپنے ماسٹر والٹ کو فنڈ کریں، اور جن سروسز کی ضرورت ہے انہیں آن کریں۔