I\'m quite new to the Facebook C# SDK (5.0.3) which probablly is the reason for this question. Basically, I\'m trying to get the current users profile, email, photo, etc etc. B
You code is correct for the most part, the only piece you were missing was the "redirect_uri" parameter when calling the "ExchangeCodeForAccessToken" method. This has to match the App URL you set up when you registered your Facebook App. Otherwise, you will get the error you were receiving. You don't need the "permissions" parameter, you have already received that during the prior authorization.
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("redirect_uri", "http://www.yourcallbackurl.com/");
var result = cl.ExchangeCodeForAccessToken(result.code,parameters);
In both the code request and access token request the redirect_uri must be the same, this will fix the OAuthException in the end. My code is now something like:
...
if (result.IsSuccess)
{
var tokenresult = cl.ExchangeCodeForAccessToken(result.Code, new Dictionary<string, object> { { "redirect_uri", "<your_redirect_uri>" } });
}
...
I think the problem is that you never get a User Access Token you only get a App Access Token. In a standalone app you need to use the oAuth Dialog. The simplest way to do this is using the Javascript SDK.
Facebook C# SDK has a sample that shows you how to do this. You could download the whole sample app (CSASPNETWebsite) as a startingpoint.