(OAuthException) An active access token must be used to query information about the current user

I'm using Facebook C# sdk with the code,

i'm trying to create a new score for a user

but i get this error:

(OAuthException) An active access token must be used to query information about the current user.

what am i missing?

protected void btnAddScore_Click(object sender, EventArgs e)
    if (CanvasAuthorizer.Authorize())
        var fb = new FacebookWebClient();
        dynamic parameters = new ExpandoObject();
        parameters.score = 77;
        parameters.access_token = GetAppAccessToken();
            dynamic id = fb.Post("me/scores", parameters);
            lblPostMessageResult.Text = "Message posted successfully";
            txtMessage.Text = string.Empty;
        catch (FacebookApiException ex)
            lblPostMessageResult.Text = ex.Message;
private string GetAppAccessToken()
    var oauthClient = new FacebookOAuthClient
        AppId = FacebookWebContext.Current.Settings.AppId,
        AppSecret = FacebookWebContext.Current.Settings.AppSecret

    dynamic result = oauthClient.GetApplicationAccessToken();
    string appAccessToken = result.access_token;
    return appAccessToken;

edit: I got the answer form here: http://facebooksdk.codeplex.com/discussions/279307

the new right code is:

if (CanvasAuthorizer.Authorize())
    var fb = new FacebookClient(CanvasAuthorizer.FacebookWebRequest.AccessToken);

    var oauthClient = new FacebookOAuthClient(FacebookApplication.Current);

    dynamic parameters = new ExpandoObject();
    parameters.score = 100;
    dynamic ac = oauthClient.GetApplicationAccessToken();
    parameters.access_token = ac.access_token;
    dynamic result = fb.Post(CanvasAuthorizer.FacebookWebRequest.UserId + "/scores", parameters);



Actually for using SCORE Graph API you need the "Application access token" which is different than a normal access token

So if you want your task to be done GET an Application access token by using the following script.......

And then replace the generated application_access_token with old access_token, that's it

The below code is written in php try convert it in c# and then apply it


$token_url =    "https://graph.facebook.com/oauth/access_token?" .
                "client_id=" . $APPLICATION_ID .
                "&client_secret=" . $APPLICATION_SECRET .
$app_token = file_get_contents($token_url);

After getting this application access token you can easily do this task.

When You Need An Application Access Token

You need to use a Facebook application access token when you have a process that acts on behalf of the application, rather than on behalf of a particular user. This happens when you access your Facebook Insights data for your app via the graph, and also when you want to create test Facebook users for your app.

Sadly, the documentation for this is buried in the authentication guide for the Facebook graph API.

Your application need to take "publish_actions" permission from user to update the score.

Refer to Create or update a score for a user section of the below documentation. https://developers.facebook.com/docs/score/

Need Your Help

Reading SIP invite packets before reaching softphone

c# wpf sockets udp sip

I'm trying to create an wpf-app that read/sniff the SIP-invite (UDP) for every incoming call to my softphone. Problem is that I can't connect to the same port. I tried to run it in administrator mo...

Java:Removing all the rows of DefaultTableModel

java swing jtable defaulttablemodel

I want to delete all the rows of DefaultTable.I found two common ways to delete them on internet but none of them works in my case because those methods does not exist in my DefaultTableModel .I wo...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.