OAuth 2.0 在 JS 中授予权限并使用服务器端的方式,(无会话)
我通过在页面步骤中间使用 FB.login() 创建了多个应用程序,并依赖 C# 获取对同一会话的访问权限,从而正确访问(并保存)用户信息。
JS:
FB.login(function (response) { if (response.session) {// user has authed} });
C#:
public FacebookSession CurrentSession { get { return (new CanvasAuthorizer()).Session; } }
两天后 Facebook 将删除会话支持,从而破坏此功能。据我了解,我现在需要重新加载页面,然后服务器端才能检测到授予的权限。 (https://developers.facebook.com/docs/authentication/)。看来我必须将用户重定向到登录框然后设置回调,或者仍然使用 javascript 但在用户授予权限后重新加载页面。
这确实令人悲伤,因为在询问任何权限并重新加载页面之前,应用程序通过向用户显示应用程序界面来运行得很好。有谁知道如何让JS再次耦合到服务器端?
I have created several apps by using FB.login() in the middle of the steps on a page, and rely on C# gaining access to the same session and thereby access (and save) the user info correctly.
JS:
FB.login(function (response) { if (response.session) {// user has authed} });
C#:
public FacebookSession CurrentSession { get { return (new CanvasAuthorizer()).Session; } }
In two days Facebook will remove the session support, which breaks this functionality. As I understand I am now required to have a page-reload before serverside can detect the granted permissions. (https://developers.facebook.com/docs/authentication/). It seems I have to either redirect the user to the login-box and then setup a callback, or still use javascript but reload the page once the user grants permissions.
This is really sad, since the apps works very well by showing the user the app-interface, before asking any permissions and reloading the page. Does anyone know how to get the JS coupled to the serverside once again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您使用的是支持新 cookie 格式的 v5.2.1,并在调用登录时在 js 中设置 oauth:true 。
您的现有代码将继续工作,无需任何服务器端 (c#) 更改。
make sure you are on v5.2.1 which supports the new cookie format and in js set oauth:true when calling login.
Your existing code will continue to work without any server side (c#) changes.