harry
harry

Reputation: 51

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

Using the Facebook C# SDK, I'm getting the following error when I try to post a status update: OAuthException: (#200) The user hasn't authorized the application to perform this action

I am getting this error only with some users. For some other,status is updating fine. App is successfully getting access for all users.

This is the full code :

public partial class Authorize : Form
    {
        public Authorize()
        {
            InitializeComponent();

        }

        public string ApplicationId 
        { 
            get 
            { 
                return ConfigurationManager.AppSettings["ApplicationId"]; 
            } 
        }

        public string ExtendedPermissions 
        { 
            get
            {
                return ConfigurationManager.AppSettings["ExtendedPermissions"];
            } 
        }

        public string AppSecret
        {
            get
            {
                return ConfigurationManager.AppSettings["ApplicationSecret"];
            }
        }

        public string AccessToken { get; set; }

        private void LoadAuthorize(object sender, EventArgs e)
        {
            var destinationURL = String.Format(
                @"https://www.facebook.com/dialog/oauth?client_id={0}&scope={1}&redirect_uri=http://www.facebook.com/connect/login_success.html&response_type=token",
                this.ApplicationId,
                this.ExtendedPermissions);
            webBrowser.Navigated += WebBrowserNavigated;
            webBrowser.Navigate(destinationURL);
        }

        private void WebBrowserNavigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            // get token
            var url = e.Url.Fragment;
            if (url.Contains("access_token") && url.Contains("#"))
            {
                this.Hide();
                url = (new Regex("#")).Replace(url, "?", 1);
                this.AccessToken = System.Web.HttpUtility.ParseQueryString(url).Get("access_token");
                //MessageBox.Show(facebookCore.AccessToken);
                try
                {
                    //var facebooking = new FacebookingTest(facebookCore.AccessToken);
                    //facebooking.UpdateStatus();
                    var fb = new FacebookClient(this.AccessToken);
                    dynamic result = fb.Post("me/feed", new { message = "Hi..Test33" });
                    var newPostId = result.id;
                }
                catch (Exception exception)
                {
                    Console.Write(exception);
                }
            }

        }
    }

Upvotes: 2

Views: 4584

Answers (1)

Mike DeVoe
Mike DeVoe

Reputation: 21

Try opening the file App.Config and modify the last line of the

<appsettings>

section as follows:

<add key="ExtendedPermissions" value="offline_access,publish_stream,publish_actions" />

Upvotes: 2

Related Questions