通过 Discord OAuth 传递字符串?
Pass a string through Discord OAuth?
我想知道是否可以使用 Discord OAuth(识别范围)同时将重要的补充信息传递给重定向 URL。
site with [important variable] > oauth page > site that needs [important variable] and oauth result
我试过添加诸如 ?variable="myString" 之类的内容,但它删除了除 OAuth 信息之外的所有不必要的 URL 参数。 Discord OAuth 也不太喜欢在 iframe 中,所以这不是解决方案。
关于这个问题我写了一篇post,你可以在这里找到:
https://levbuchel.com/passing-variables-through-oauth
原回答:
要通过 oAuth 进程传递变量,您应该使用 state
oAuth 参数。
首先用您的参数创建一个 Json 字符串,
例如{'first':'111', 'second':'222'}
.
然后编码为base64,这样在作为URL传递时不会被修改。
将此字符串作为 state
(api/oauth2/authorize?response_type=token&state=whatEverYouGotAsState
) 传递。
然后您将能够在您的重定向 URI 上接收并解码它。
我想知道是否可以使用 Discord OAuth(识别范围)同时将重要的补充信息传递给重定向 URL。
site with [important variable] > oauth page > site that needs [important variable] and oauth result
我试过添加诸如 ?variable="myString" 之类的内容,但它删除了除 OAuth 信息之外的所有不必要的 URL 参数。 Discord OAuth 也不太喜欢在 iframe 中,所以这不是解决方案。
关于这个问题我写了一篇post,你可以在这里找到:
https://levbuchel.com/passing-variables-through-oauth
原回答:
要通过 oAuth 进程传递变量,您应该使用 state
oAuth 参数。
首先用您的参数创建一个 Json 字符串,
例如{'first':'111', 'second':'222'}
.
然后编码为base64,这样在作为URL传递时不会被修改。
将此字符串作为 state
(api/oauth2/authorize?response_type=token&state=whatEverYouGotAsState
) 传递。
然后您将能够在您的重定向 URI 上接收并解码它。