डेवलपर संदर्भ

अपने बैकएंड से टोकन जारी करना

जॉइन टोकन बनाने का समर्थित तरीका — और वह एक फ़ील्ड, जिसके छूटते ही सिंगल-सेशन नियंत्रण चुपचाप बंद हो जाता है।

डेवलपर उत्पादों पर लौटें

बैकएंड से क्यों?

आपका सर्वर सीक्रेट कभी ऐप में नहीं जाना चाहिए। 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.
client_ipstringअनुशंसितThe END USER's public IP address, forwarded from your server. We see the address of whoever calls this endpoint — which, once you mint from your backend, is your data centre for every one of your users. That address decides the country we stamp on the participant AND which media node a new room opens on, so leaving it out can seat a Riyadh audience next to your server instead of next to them. Only honoured on a server-authenticated request (never app_key, where the handset's own address is already correct), and a private or malformed value is ignored rather than rejected.
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.

आपके सर्वर पर

सीक्रेट सिर्फ़ यहीं रहता है। चिह्नित फ़ील्ड ऐप से आते हैं — सर्वर इन्हें स्वयं नहीं जान सकता।

mint-token.js
// 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,

    // 🔴 The user's own IP, not your server's. Without it every user of yours
    // is placed and geo-located as if they sat in your data centre.
    client_ip: req.headers["x-forwarded-for"]?.split(",")[0]?.trim() ?? req.ip,

    // 🔴 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,
  }),
});

आपके ऐप में

डिवाइस की जानकारी अपने बैकएंड को भेजें, वह आगे भेजेगा। डिवाइस आईडी ऐप रीस्टार्ट के बाद भी वही रहनी चाहिए।

request_token.dart
// 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_bannedThis user is banned from this room.Show them they were removed. This is the ONLY code that should produce that message.
room_type_disabledThe project does not have this room type enabled.A configuration problem, not a user problem. Never show a removal notice.
streaming_disabledThe streaming service is not enabled for this project.Same — configuration, not the user.
appkey_identity_mint_disabledYou 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 / bearer

Your backend, authenticated with your server secret. The recommended path.

app_key

The device, using the publishable app key. The legacy path — being closed.

UTD के साथ बनाने के लिए तैयार हैं?

अपना अकाउंट बनाएँ, अपने मास्टर वॉलेट को फंड करें, और अपनी ज़रूरत की सेवाएँ चालू करें।