小编nor*_*dev的帖子

Discord OAuth2 重定向 URI 操作方法

我正在尝试制作一个可以加入其他服务器的不和谐机器人(带有机器人标签)。

如果我可以为其设置重定向 URI,我就能做到这一点。我已经设置了机器人帐户,并且它已经可以使用它(除了加入服务器)。

我想知道如何为不和谐 OAuth2 设置重定向 URI?

uri bots oauth-2.0

4
推荐指数
1
解决办法
13万
查看次数

Discord OAuth2 redirect_uri 组件的问题

我目前正在为我的 Web 应用程序开发 Discord OAuth2 客户端。

无论我多么努力地设置redirect_uri以使discord不发送错误,我都无法修复它,并且我不断收到此消息:

无效的 OAuth2 redirect_uri :您现在可以关闭此选项卡。

截屏 (对不起第二行的外语)

我的 redirect_uri 是:

const redirect = encodeURIComponent("http://localhost/callback");

(该网站存在于服务器上并正常工作。)

**我尝试了很多组合,包括: - 添加 https:// 而不是 http:// - 添加.com到域 - 在单词后添加斜杠callback - 使用普通字符串而不是 encodeURIComponent - 通过 Discord Developer 生成 oauth2 redirect_uri页 **

唯一有效的是从 URL 参数中完全删除了 redirect_uri,这使应用程序正常工作,但之后没有重定向到正确的位置;

(这是我的 oauth2 网址):

https://discordapp.com/api/oauth2/authorize?client_id=${id}&redirect_uri=${redirect}&response_type=code&scope=identify%20guilds%20email,

什么时候id = client id in string typeredirect = (above) the url

谢谢你的帮助。

编辑 1:有意将 redirect_uri 设置为错误的 URL,发送一条 JSON 消息说“格式错误的 redirect_uri”。(不是屏幕截图上可见的那个!)

编辑2:示例完整网址: https://discordapp.com/oauth2/authorize?client_id=528972063096963140&redirect_uri=http%3A%2F%2Flocalhost%2Fdiscord%2Fcallback&response_type=code&scope=identify%20guilds%20email

node.js oauth-2.0 express discord

4
推荐指数
3
解决办法
1万
查看次数

标签 统计

oauth-2.0 ×2

bots ×1

discord ×1

express ×1

node.js ×1

uri ×1