-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wildtoken #3212
base: fix-4.2.2-release-notes
Are you sure you want to change the base?
wildtoken #3212
Conversation
用户在加入音视频通话或直播时,声网会使用 Token 对用户鉴权。观众如果需要加入多个频道,或在频道间频繁切换,每加入一个新的频道都需要向服务端申请一个 Token,然后通过用户 ID、频道名、以及获取到的 Token 来加入频道。为解决观众在切换频道时需要频繁申请 Token 的问题,声网提供了基于频道通配符的 Token。通过使用通配 Token,观众可以复用同一个 Token 加入不同频道,既可减少频繁获取 Token 所造成的耗时,从而加快切换、加入频道的速度,同时也能减小你的 Token 服务器的压力。 | ||
|
||
本文以 Android 平台为例,介绍如何生成通配 Token。 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我看了一下生成通配 Token 这个 section,感觉:
-
参考 AccessToken2 的内容和区别于 AccessToken2 的内容是揉在一起的,会稍微有点乱,最好拆一下:
- 部署服务器可以完全参考 AccessToken2 的,放在 ## 前提条件
- Token 生成器有两个参数字段区别于普通 Token,需要重点突出出来,放在 ## 生成通配 Token
-
文中提到“以 BuildTokenWithUid[1/2] 为例,xxxx”,这个说法感觉不太准确,实际上
BuildTokenWithUid
[2/2] 应该是一样的情况,它们的区别只是过期时间的设置,生成通配 Token 都需要注意uid
和chnannelName
参数。 -
提到 “本文以 Android 平台为例”,但是链接给的是 cpp 的,然后也没有 java 的示例代码,所以没太懂为啥以 Android 为例。。因为 token 的部署服务器部分是全平台一致的,或许是想说客户端实现以 Android 为例(但是这篇和客户端的部分好像也没啥关系?
![image](https://private-user-images.githubusercontent.com/101544891/251703578-1f2be1d2-9d47-49fe-95d9-84051c47a4fe.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAyNzE4ODksIm5iZiI6MTcyMDI3MTU4OSwicGF0aCI6Ii8xMDE1NDQ4OTEvMjUxNzAzNTc4LTFmMmJlMWQyLTlkNDctNDlmZS05NWQ5LTg0MDUxYzQ3YTRmZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzA2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwNlQxMzEzMDlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01OGMwMzZjOTkwNWE2MzAwNzE4OThmZmFiZjdhNTdhNmQzM2Y1YzA5NjQ0N2I3YTI2MTc2ZjhiN2I3OTlkM2ZhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.CS5fbhStcgSxfy8lKw3t1aI7od-vm5e8sYrKoEYODBA)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
本文以 Android 平台为例,介绍如何生成通配 Token。 | ||
|
||
## 生成通配 Token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得可以这样写(当然我可能理解得不到位,你参考一下看看
前提条件
在生成通配 Token 前,请确保你已部署 AccessToken2 服务器。详见使用 Token 鉴权。
- 如果你使用的是 AccessToken,请参考 AccessToken 升级指南升级至 AccessToken2。
- 如果你使用的是 Web 端,需要调用
setParameter
将USE_NEW_TOKEN
设为true
。
生成通配 Token
AccessToken2 的生成器代码中提供两个 BuildTokenWithUid
方法,你可以根据 BuildTokenWithUid API 参考 按需选用 BuildTokenWithUid
[1/2] 或 BuildTokenWithUid
[2/2],并填入对应参数信息。
生成通配 Token 时,需要注意以下参数的填写与普通 Token 有别:
参数 | 普通 Token | 通配 Token |
---|---|---|
uid |
待鉴权用户的用户 ID xxxxxxxx,请把 uid 设为 0。 | 不能设置为 0(支持使用 int 、String 型的用户 ID)。 (//这里最好解释一下为什么不能设为0?) |
channelName |
频道名称,长度在 64 个字节以内。xxxxxx | 频道名设为通配符 * ,表示任意频道。 |
以 Java 为例,示例代码如下:
// 有给示例代码么?给一个比较好
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
示例代码就是跟accesstoken2生成的一样,只不过替换一下channelname为*。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你这样确实更清晰~
No description provided.