【问题标题】:(OAuthException - #200) (#200) The user hasn't authorized the application to perform this action(OAuthException - #200) (#200) 用户未授权应用程序执行此操作
【发布时间】:2016-05-31 17:38:39
【问题描述】:

我正在试用 facebook api。我收到此错误,我无权执行此操作。我已经接受了运行程序时出现的所有弹出窗口。有人对此有快速解决方案吗?

sing Facebook;



        public void CheckAutorization()
        {
            string app_Id = "xxxxxxxxxxxxxxx";
            string app_secret = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy";
            string scope = "publish_stream, manage_pages";

            if (Request["code"] == null)
            {
                Response.Redirect(string.Format(
                    "https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}",
                    app_Id, Request.Url.AbsoluteUri, scope));
            }
            else
            {
                Dictionary<string, string> tokens = new Dictionary<string, string>();

                string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}",
                    app_Id, Request.Url.AbsoluteUri, scope, Request["code"].ToString(), app_secret);

                HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;

                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    StreamReader reader = new StreamReader(response.GetResponseStream());

                    string vals = reader.ReadToEnd();

                    foreach (string token in vals.Split('&'))
                    {
                        //meh.aspx?token1=steve&token2=jake&...
                        tokens.Add(token.Substring(0, token.IndexOf("=")),
                            token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
                    }
                }

                string access_token = tokens["access_token"];

                var client = new FacebookClient(access_token);

                client.Post("/me/feed", new { message = "Is there anyone out there? :) Can i get a whoop whoop" });
            }
        }
    }
}

【问题讨论】:

标签: facebook facebook-c#-sdk facebook-sdk-4.0


【解决方案1】:

必须将范围字符串 scope = "publish_stream, manage_pages" 更改为字符串 scope = "publish_stream, publish_actions";

【讨论】:

  • 如何获取所有范围的列表:publish_stream、publish_actions、manage_pages 等??
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多