用Facebook登录,获取访问令牌 [英] Login with Facebook, grab access token

查看:314
本文介绍了用Facebook登录,获取访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要登录Facebook并打印/存储Oauth响应中给出的访问令牌即可.我正在使用以下代码来启动登录:

I just need to login to Facebook and print/store the Access Token given in the Oauth response. I'm using the following code to initiate login:

    <script>
    (function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.9&appId=ID_REDACTED";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    </script>
    <div class="fb-login-button" data-max-rows="1" data-size="large" data-button-type="continue_with" data-show-faces="false" data-auto-logout-link="false" data-use-continue-as="false"></div>

当我加载页面并单击继续使用Facebook"按钮并允许通过弹出窗口访问应用程序时,OAuth请求将发送到Facebook.com,并且在响应中,我的所有数据都包括在内(包括访问权限)令牌).我无法弄清楚如何访问此数据,因为它没有发送到我的服务器.

When I load the page and click the "Continue With Facebook" button and allow the app access via the popup, an OAuth request is sent to Facebook.com and in the response, all of my data is include (including the Access Token). I can't figure out how to access this data since it's not sent to my server.

感谢您的帮助,谢谢.

推荐答案

请参阅getLoginStatus()的文档: https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus

Please see documentation for getLoginStatus(): https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus

回调中的响应对象将具有此信息

The response object in the callback will have this info

这篇关于用Facebook登录,获取访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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