VK Oauth:安全错误

VK Oauth: Security Error

我正在尝试授权我的独立应用程序。但是在我点击 "Allow" 之后,它总是重定向到 http://oauth.vk.com/error?err=2 并将其作为响应正文:

{"error":"invalid_request", "error_description":"Security Error"}

这是请求 URL(我确实有正确的 client_id):

https://oauth.vk.com/authorize?client_id=...&scope=messages,offline&redirect_uri=https://oauth.vk.com/blank.html&display=page&v=5.37&response_type=token

看来我什么都试过了:

经过一个小时的搜索,我找到了 this

所以,这意味着用户有一个旧会话,必须在浏览器中重新登录。

Space in state 参数导致了这个。

OAuth 2 RFC, sections 4.1.1 on authorization request and 4.1.2 on authorization response,建议使用 state 参数来维护授权代码流中的状态,特别是防止 CSRF。

当我将此字段设置为 CSRFTOKEN123 http://my.site/next/url 时,出现此错误。将 (space) 替换为 : 以获得 CSRFTOKEN123:http://my.site/next/url 帮助。

顺便说一下,我在 VK 文档网站上找不到任何关于 state 参数的提及,但 VK OAuth 2 授权系统实际上支持它。否则就不能称为 OAuth 2。所以我发现使用 state 参数是合法的。

主题https://vk.com/topic-17680044_30635058 mentioned by author is closed now, current discussion is https://vk.com/topic-1_24428376. There are number of questions on this。全部为俄语。