如何在FB身份验证之后和FB授权之前进行检测 [英] how to detect after FB authentication and before FB authorization

查看:114
本文介绍了如何在FB身份验证之后和FB授权之前进行检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的MVC应用程序中,我在JQuery中有以下代码来检查用户是否已连接到Facebook应用程序

In my MVC application, I have below code in JQuery to check if user is connected to Facebook app or not

FB.login(function (response) {
    switch (response.status) {
        case "connected":
        case "unknown":
            break;
    }

}, { scope: "@MyPermissions" });

现在,当我通过我的应用程序进行FB登录时,它将进行身份验证并立即启动FB应用程序授权,最后在完成授权后进入Connected案例.

Now, when I do FB login through my app, it authenticates and immediately starts FB app authorization and finally it comes to Connected case, when authorization is done.

我的问题是:我可以检测Facebook身份验证何时完成以及授权开始之前吗?这样我的调试器就可以在授权发生之前抓住位置.我必须避免使用授权.

My Question is : Can I detect when Facebook authentication in done and before authorization starts ? So that my debugger can catch the position before authorization takes place. I have to actually avoid the authorization.

推荐答案

oAuth实际上是两步授权,您不能在身份验证时停止它.

Actually oAuth is two steps authorization you cannot stop it at authentication.

您可以做个窍门,通常人们已经登录到Facebook,因此您可以在首次加载时尝试getLoginStatus(),因为它尚未授权您的应用,因此可以肯定会返回not_authorized,您可以执行检查他们,然后获得用户授权.

You can do a trick, Usually people are at already login to facebook therefore you can try getLoginStatus() on first load which will sure surely return you not_authorized as it has not yet authorize your app, You can perform your check their and then get user authorize.

FB.getLoginStatus(function(response) {
  if (response.status === 'not_authorized') {
    // the user is logged in to Facebook, 
    // but has not authenticated your app


  } else {
    // the user isn't logged in to Facebook.
  }
 });

这篇关于如何在FB身份验证之后和FB授权之前进行检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆