【问题标题】:Cordova/Phonegap facebook plugin An active access token must be used to query informationCordova/Phonegap facebook 插件 必须使用主动访问令牌来查询信息
【发布时间】:2017-07-21 14:43:06
【问题描述】:

我正在使用 https://github.com/Wizcorp/phonegap-facebook-plugin 将我的 cordova Android 应用程序连接到 Facebook。
我可以使用:
facebookConnectPlugin.login(["email"], fbLoginSuccess, function (error) { alert("ERROR:" + JSON.stringify(error)); } ); 登录,注销甚至调用 facebookConnectPlugin.getLoginStatus 并获得:

  • 用户ID
  • 访问令牌
  • 过期时间
  • 信号
  • 状态

但是当FB.api('/me', function(response){...}) 被调用时,我收到 {error: { message: An active access token must be used to query information about the current user, type: OAuthException, code: 2500 } }
此外,这仅在构建应用程序时发生,而不是在浏览器中测试。

【问题讨论】:

    标签: android facebook cordova oauth


    【解决方案1】:

    通过手动给FB.apicall 一个令牌解决了这个问题: FB.api('/me?access_token='+userdata.authResponse.accessToken, function(response) {... 其中userdatafacebookConnectPlugin.getLoginStatus 的响应
    我只是不明白为什么它不像在浏览器中那样在android应用程序中自动提供令牌。

    【讨论】:

      【解决方案2】:

      使用 apiString 发送访问令牌和数据检索字段

        const fields = ['email', 'first_name', 'last_name', 'gender', 'birthday', 'picture.type(large)'];
        const apiString = `me?access_token=${accessToken}&fields=${fields.join(',')}`;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-11-27
        • 1970-01-01
        • 1970-01-01
        • 2012-10-19
        • 2011-08-27
        • 2016-08-13
        • 2013-04-07
        • 2012-04-26
        相关资源
        最近更新 更多