अपने बैकएंड से टोकन जारी करना
जॉइन टोकन बनाने का समर्थित तरीका — और वह एक फ़ील्ड, जिसके छूटते ही सिंगल-सेशन नियंत्रण चुपचाप बंद हो जाता है।
बैकएंड से क्यों?
आपका सर्वर सीक्रेट कभी ऐप में नहीं जाना चाहिए। 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. |
आपके सर्वर पर
सीक्रेट सिर्फ़ यहीं रहता है। चिह्नित फ़ील्ड ऐप से आते हैं — सर्वर इन्हें स्वयं नहीं जान सकता।
// 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,
}),
});आपके ऐप में
डिवाइस की जानकारी अपने बैकएंड को भेजें, वह आगे भेजेगा। डिवाइस आईडी ऐप रीस्टार्ट के बाद भी वही रहनी चाहिए।
// 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 के साथ बनाने के लिए तैयार हैं?
अपना अकाउंट बनाएँ, अपने मास्टर वॉलेट को फंड करें, और अपनी ज़रूरत की सेवाएँ चालू करें।