facebook-csharp-sdk/facebook-csharp-sdk — Issue #90: An access token is required to request this resource / FQL issue
Author: chiatdev1
Created: 2012-02-22 18:53:56+00:00
State: open

I have a command line application which executes a query.

Problem is that it receives an access token of the form "abc...|xyz...". There is no session portion. But the token returned is useless for executing my query to select insights for a page of mine.

Here is the code:

dynamic ExecuteMyQuery (string username, string password, string MY_PAGE_ID)
{

const string permissions = "manage_pages,read_insights,offline_access";

dynamic oauthClient = new FacebookOAuthClient() ;
oauthClient.AppId = username ;
oauthClient.AppSecret = password ;

dynamic parameters = new ExpandoObject() ;
parameters.scope = permissions ;
parameters.response_type = "token" ;
// parameters.grant_type = "client_credentials" ;

dynamic result = oauthClient.GetApplicationAccessToken(parameters);
string token = result.access_token ;
// token comes back as "abc...|xyz..."

var fb = new FacebookClient(token);
string query = " select metric, value " +
" from insights " +
" where object_id = " + MY_PAGE_ID + " and " +
" metric in ( 'page_impressions' , 'page_stories') and " +
" end_time >= end_time_date('2012-02-21') and " +
" end_time <= end_time_date('2012-02-11') and " +
" period = period('day') " ;

dynamic result2 = fb.Query(query) ; // Exception generated on this line.

return result2 ;
}