Facebook Api Permissions .Net
本文关键字:Net Permissions Api Facebook | 更新日期: 2023-09-27 18:02:58
string OAuthURL = @"http://www.facebook.com/dialog/oauth?client_id=app_id
&redirect_uri=http://www.facebook.com/connect/login_success.html
&redirect_type=token
&scope=publish_actions,user_photos";
dynamic result = fb.Get("oauth/access_token", new
{
client_id = "app_id",
client_secret = "app_secret",
redirect_uri = "http://www.facebook.com/connect/login_success.html",
code = code,
scope = "publish_actions,user_photos"
});
我已经尝试了上面的两段代码,但我不能给帐户权限。这会导致一些错误,比如发布一些东西。此外,当我使用fb.Get("/me/permissions")获取权限时,我用scope编写的权限都不存在。我的意思是在这里看不到publish_stream或user_photos权限。因此,我得到一个错误
(oautheexception -#200)(#200)用户没有授权应用程序执行此操作。
我能做些什么来给我的应用程序权限,或者我如何解决这个问题?
您可以像这样获得accestoken
if (code == "" || code == null)
{
//request for authentication
Response.Redirect("https://graph.facebook.com/oauth/authorize?client_id=" + appId + "&redirect_uri=http://localhost:5176/");
}
else
{
fb = new MyFB();
fb.ApplicationSecret = appSecret;
fb.ApplicationID = appId;
string accessToken = fb.GetAccessToken(code);
fb.AccessToken = accessToken;
ViewData["MyName"] = fb.GetMyName();
}
我建议您使用本教程作为将来的参考:http://codesamplez.com/facebook-c-sharp-api-tutorials
你必须获得facebook graph API explorer的许可。你必须去
图形API资源管理器->选择您的应用程序->获取访问令牌
会有一个权限列表,你只需要检查你想要的权限。然后你可以从c#代码中批准你的令牌。