从javascript调用任何FB api时的OAuthException 2500

时间:2021-09-04 19:13:35

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. On the server side I’m able to do everything, but from the client side, using JavaScript, I can’t make any calls. On the server side I store the authorization token and I’ve tried pulling it back and passing it to Facebook as follows:

我使用Facebook应用程序模板进行MVC4。在服务器端,我可以做任何事情,但从客户端,使用JavaScript,我无法拨打任何电话。在服务器端,我存储了授权令牌,我尝试将其拉回并将其传递给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. The layout page has all of the fb init stuff.

返回相同的东西。这段代码是作为$(document).ready setup的一部分调用的。布局页面包含所有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,但它从不提供响应。

1 个解决方案

#1


-1  

a short workaround should using FB.api('userId'); instead.

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

#1


-1  

a short workaround should using FB.api('userId'); instead.

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