Token 与 uid 映射
构建时从公开 REST 接口定义的 `tokens` 标签生成:方法、路径、参数、请求体、响应与 curl。
分组概览
本页由公开 REST 接口定义在构建时生成:标签 tokens,共 5 个操作(全量 189 个)。鉴权、信封与分页约定见 REST API 总览.
| 方法 | 路径 | 摘要 |
|---|---|---|
GET | /v1/meta/privileges | Privilege catalogue per role |
POST | /v1/tokens | Issue a channel token |
POST | /v1/tokens/renew | Renew a token |
GET | /v1/tokens/verify | Verify a token and return its payload |
POST | /v1/uids:resolve | Resolve rtc uids to IM user ids |
操作详情
GET /v1/meta/privileges
Privilege catalogue per role
鉴权:项目凭证(customerId:customerSecret 的 Base64)
响应
| 状态码 | 说明 / schema |
|---|---|
200 | privilege catalogue per role — object{ privileges, roles } |
调用示例
curl -s -X GET "$NIMEET_API_BASE/v1/meta/privileges" \
-H "Authorization: Basic $NIMEET_CUSTOMER_BASIC"POST /v1/tokens
Issue a channel token
getRTCTokenInfo implementation for the IM RTC Provider. Wildcard tokens (channelName: "*" or wildcard: true) are allowed; uid may be supplied explicitly or derived from userId.
鉴权:项目凭证(customerId:customerSecret 的 Base64)
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
channelName | string | ||
channel | string | alias of channelName | |
uid | integer | 1..2147483647 | |
userId | string | IM user id; when supplied the rtcUid is derived and bound | |
role | enum(host | audience) | 默认 "host" | |
ttlSeconds | integer | 60..86400 | |
wildcard | boolean |
{
"channelName": "weekly-sync",
"uid": 10001,
"role": "host",
"ttlSeconds": 3600
}响应
| 状态码 | 说明 / schema |
|---|---|
200 | issued — TokenIssueResponse |
400 | Invalid parameter — Error |
401 | Missing/invalid credentials — Error |
403 | Banned or service not enabled — Error |
415 | Content-Type must be application/json — Error |
调用示例
curl -s -X POST "$NIMEET_API_BASE/v1/tokens" \
-H "Authorization: Basic $NIMEET_CUSTOMER_BASIC" \
-H "Content-Type: application/json" \
-d '{"channelName":"weekly-sync","uid":10001,"role":"host","ttlSeconds":3600}'POST /v1/tokens/renew
Renew a token
Accepts a token within its renewal grace window and returns a fresh token with the same channel, uid and (non-escalated) privileges.
鉴权:项目凭证(customerId:customerSecret 的 Base64)
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
token | string | 是 |
{
"token": "$RTC_TOKEN"
}响应
| 状态码 | 说明 / schema |
|---|---|
200 | renewed — TokenIssueResponse |
400 | Invalid parameter — Error |
401 | Missing/invalid credentials — Error |
调用示例
curl -s -X POST "$NIMEET_API_BASE/v1/tokens/renew" \
-H "Authorization: Basic $NIMEET_CUSTOMER_BASIC" \
-H "Content-Type: application/json" \
-d '{"token":"$RTC_TOKEN"}'GET /v1/tokens/verify
Verify a token and return its payload
鉴权:项目凭证(customerId:customerSecret 的 Base64)
参数
| 名称 | 位置 | 必填 | 类型 | 说明 |
|---|---|---|---|---|
token | query | 是 | string | |
channelName | query | string |
响应
| 状态码 | 说明 / schema |
|---|---|
200 | valid — object{ valid, payload } |
400 | Invalid parameter — Error |
401 | Missing/invalid credentials — Error |
调用示例
curl -s -X GET "$NIMEET_API_BASE/v1/tokens/verify?token=%24RTC_TOKEN&channelName=weekly-sync" \
-H "Authorization: Basic $NIMEET_CUSTOMER_BASIC"POST /v1/uids:resolve
Resolve rtc uids to IM user ids
getUserIdsWithRTCUids implementation. Partial results are returned; unknown uids are omitted.
鉴权:项目凭证(customerId:customerSecret 的 Base64)
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
rtcUids | array<integer> | 是 | 最多 200 项 |
channelName | string |
{
"rtcUids": [
10001,
10002,
99999
],
"channelName": "weekly-sync"
}响应
| 状态码 | 说明 / schema |
|---|---|
200 | mapping keyed by uid — object |
400 | Invalid parameter — Error |
401 | Missing/invalid credentials — Error |
调用示例
curl -s -X POST "$NIMEET_API_BASE/v1/uids:resolve" \
-H "Authorization: Basic $NIMEET_CUSTOMER_BASIC" \
-H "Content-Type: application/json" \
-d '{"rtcUids":[10001,10002,99999],"channelName":"weekly-sync"}'本分组用到的 Schema
Error — object{ code, message, reason, sdkCode, details }
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | string | 是 | stable machine code, see errors.json |
message | string | 是 | |
reason | string | ||
sdkCode | integer | Agora-aligned client error number | |
details | object |
TokenIssueResponse — object
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
appId | string | 是 | |
channelName | string | 是 | |
rtcToken | string | 是 | |
rtcUid | integer | 是 | 1..2147483647 |
role | enum(host | audience) | 是 | |
privileges | array<string> | 是 | |
controlToken | string | Opaque control-plane token for REST diagnostics/renewal. TokenIssueResult.controlToken is optional; toResult() always sets it. | |
mediaRoom | string | SFU room name when the media adapter namespaces by App ID (TokenIssueResult.mediaRoom). | |
expireAt | string | 是 | format date-time |
privilegeExpireAt | string | 是 | format date-time |