当用户到达已登录的我的Facebook应用程序时,如何检测取消的权限请求? [英] how do I detect a cancelled permissions request when the user arrives at my facebook app already logged in?

查看:124
本文介绍了当用户到达已登录的我的Facebook应用程序时,如何检测取消的权限请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在测试javascript sdk的身份验证/登录代码,但我注意到,只有当用户到达我的应用程序时,facebook才检测到取消的权限请求,而该用户尚未登录facebook,但是如果用户已经登录到Facebook,并且他们取消了相同的权限请求,FB.login不会像在第一种情况下那样返回未知"状态.

I've been testing the auth/login code for the javascript sdk and I've noticed that facebook only detects the cancelled permissions request when a user arrives at my app not logged into facebook, but if a user is already logged in to facebook and they cancel the same permissions request, FB.login doesn't return the "unknown" status the way it does under the first condition.

$("button").click(function(){            

    FB.login(function(response) {

        /*when the user clicks the button but isn't logged in, fb will prompt
        them to log in and then shows the dialogue where I request
        permissions. If I hit cancel, the response status will return
        "unknown" and I redirect to another page. */    

        if(response.status === "unknown"){
            top.location.href = "https://developers.facebook.com/docs/facebook-login/access-tokens/";

        }else{
            /*However if the user is already logged in and the permissions
            request is cancelled, the code goes into this block that is meant to
            handle a "connected" response */

            console.log("connected");                           
            },{scope: 'user_location,user_likes'});

    });

推荐答案

如果要验证是否已获得所有必需的权限,则可以进行FB.api('/me/permissions', function(perms) { ... });

If you want to verify that you've been granted all the needed permissions, then you can make an api call like FB.api('/me/permissions', function(perms) { ... });

这篇关于当用户到达已登录的我的Facebook应用程序时,如何检测取消的权限请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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