简体   繁体   English

从javascript调用任何FB API时发生OAuthException 2500

[英]OAuthException 2500 when calling any FB api from javascript

Problem: I keep getting the following error from Facebook : 问题: 我不断从Facebook得到以下错误

Code: 2500
Message: "An active access token must be used to query information about the current user."
Type: OAuthException

The call I made is: 我打的电话是:

Function TestResponse(response) {….}
FB.api(‘/me’, TestResponse);

I used the Facebook Application template for MVC4. 我为MVC4使用了Facebook Application模板。 On the server side I'm able to do everything, but from the client side, using JavaScript, I can't make any calls. 在服务器端,我能够执行所有操作,但是从客户端使用JavaScript,我无法进行任何调用。 On the server side I store the authorization token and I've tried pulling it back and passing it to Facebook as follows: 在服务器端,我存储了授权令牌,并尝试将其撤回并将其传递给Facebook,如下所示:

var parameters = { access_token: $('#AccessToken').val() };
FB.api('/me', parameters, TestResponse);

Returns the same thing. 返回相同的东西。 This code is called from as part of my $(document).ready setup. 此代码是从我的$ {document).ready设置中调用的。 The layout page has all of the fb init stuff. 布局页面包含所有fb init内容。

As mentioned: from C# I can make calls to the facebook API and things work, but I'd really like to do most of the work from JavaScript to avoid having an extra round trip thrown in to my application. 如前所述:从C#中,我可以调用facebook API,并且一切正常,但是我真的很想从JavaScript中完成大部分工作,以避免不必要的往返于我的应用程序中。

also: I've tried calling getLoginStatus but it never provides a response. 还:我尝试过调用getLoginStatus,但它从未提供响应。

a short workaround should using FB.api('userId'); 一个简短的解决方法应该使用FB.api('userId'); instead. 代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM