Facebook C# SDK and OAuth Server-side flow in ASP.NET 4
I am working on a Silverlight 4 browser app from which I managed to succeed in complete the client-side flow authentication process. I've decided to better move to the server-side flow but, though I provide the same redirect_uri as I provided in the client-side flow once I get the "code" from Facebook, I am not getting automatically redirected to the uri I've set (I do get the access_token if I retrieve the response as string)
I am making the requests from an .aspx page:
var client = new WebClient();
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
var encoding = new ASCIIEncoding();
var inputs = new NameValueCollection
{
{"client_id", appId},
{"redirect_uri", "http://localhost:57613/CallbackForm.aspx"},
{"client_s开发者_JS百科ecret", "XXXXX"},
{"code", Code}
};
var result = encoding.GetChars(client.UploadValues("https://graph.facebook.com/oauth/access_token", inputs));
string asciiString = new string(result);
But now the problem is that I need my page to be redirected with the access_token passed by URL in order to get my Silverlight control reloaded as well (it is hosted in the same .aspx page where I have this code snippet), because I need the silverlight content being loaded again to complete the only way I know to get the access token from the .aspx page (calling a javascript function from silverlight). Could somebody help me and explain how can I get the page redirected when querying for the access_token, or how can I pass the access_token to the silverlight control in a different way?
Thanks so much
There has been a change in Facebook behavior regarding the structure of the query string. This is discussed in http://facebooksdk.codeplex.com/discussions/261528. This link discussed a change to the auth procedure which should fix your issue. My code uses WPF and not Silverlight; I'm not sure whether the same issue applies to the Silverlight control.
Also see Does Facebook Client-Side Flow still give out access tokens? and SL4 Facebook application no longer retrieves access_token.
精彩评论