Facebook permission dialog (JavaScript sdk)

2020-06-25 18:59发布

I am using OAuth Dialog for Facebook permission to access a users' email, birthday and other details but when I run this app URL that is https://apps.facebook.com/projectatestapp/ (while being logged into Facebook) I see this login to app window which says:

You are logging into testapp as Nina Sewart. Logging in will not add this app's activity to Facebook.

With log in and cancel button instead of Permission window with Allow and Don't Allow button

here is my code

<html xmlns:fb="https://www.facebook.com/2008/fbml">
<body>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <div id="fb-root"></div>
    <script>
        FB.init({ 
            appId: '[My app id]', 
            xfbml: true, 
            cookie: true,
            oauth: true
        });

        FB.login({
            scope: 'email,user_birthday',
        });
    </script>

    <a href="https://www.facebook.com/dialog/oauth/?scope=email,
        user_birthday&
        client_id=148244388606048&
        redirect_uri=https://apps.facebook.com/projectatestapp/test2.html&
        response_type=token" target="_top">test</a>
</body>
</html>

Please tell me whats wrong in it?

4条回答
看我几分像从前
2楼-- · 2020-06-25 19:29

I have the same issues here. The documentation says only developers/tester of this app will be able to get the publish permission but I could manage to make it work only with the id that was used to create the app. Other test users (even though are authorized developers) are not able to get past the 'add-to-timeline' stage.

It could be a major bug.

查看更多
小情绪 Triste *
3楼-- · 2020-06-25 19:30

The reason you are not seeing it is because the application process has become a two step process.

  1. Being that the person accepts to login into your application.
  2. Being the person accept your extended permission which is where the callback url comes into play.

Documentation can be found here.

So the reason your callback isn't being called is because the two step process. I would suggest making the response attached to second page that is called.

I am not sure how the JS SDK works but it is how I managed to do it.

Goodluck.

查看更多
看我几分像从前
4楼-- · 2020-06-25 19:30

You need before calling autorization window to add the fb token to the url to identify your user to fb.

I think try this to get the token : FB.getAccessToken();

查看更多
forever°为你锁心
5楼-- · 2020-06-25 19:39

I was struggling with this issue for few hours, and my lovely co-worker helped me fix it just now. Make sure you don't refresh the page after login was called. Basically, don't do something like below:

FB.login(...);
window.location.refresh();

Include the refresh code inside of the callback for FB.login!

Man, I feel so stupid, but sometimes you get confused and forget how callbacks work in terms of execution orders of code.

查看更多
登录 后发表回答