获得Facebook的访问令牌在C#令牌、Facebook

2023-09-03 04:36:22 作者:霸道小男人ゞ

var fb = new FacebookClient();

dynamic result = fb.Get("oauth/access_token", new
{
      client_id = "MyAppId",
      client_secret = "MyAppSecret",
      redirect_uri = "http://www.facebook.com/connect/login_success.html",
      code = "code"
});

fb.AccessToken = result.access_token;

我用这块code获得Facebook的访问令牌。当我尝试登录的任何账户,是没有问题的。但是,如果我尝试发布一些该帐户的墙,我得到一个错误,这是;

I use this piece of code to get facebook access token. When I try to login with any account, there is no problem. However, if I try to post something on that account's wall, I get an error which is;

(OAuthException-#200)(#200)的用户没有授权的应用程序   执行此操作。

(OAuthException-#200)(#200) The user hasn't authorized the application to perform this action.

另外我想补充一点,如果我手动得到图形API浏览器的访问令牌中developers.facebook.com,并用它在我的code的访问令牌,我可以张贴。

Also I want to add that if I get the access token from graph api explorer in developers.facebook.com manually and use it in my code as access token, I can post.

PS:我给publish_actions权限的帐户,并没有什么改变。

P.S: I gave "publish_actions" permission to the account and nothing is changed.

推荐答案

你能确认你的使用所要求的权限/ {用户ID} /权限?

Can you verify that your have requested permissions using /{user-id}/permissions ?

请参阅 https://developers.facebook.com/docs/facebook -login /许可/ V2.4 了解详细信息。