CanvasAutorize - redirection to facebook permissions dialog clears the request_ids query string sent when user accepts an app request
When a user accepts my application request, the user is redirected to my app page with a parameter request_ids which is the request id info for 开发者_JS百科that application request. The problem is that my app page has the [CanvasAuthorize] attribute that redirects the user to the permissions grant dialog and when user accepts it it returns the app entry point, but during this transfer i lose the request_ids querystring and cannot use the request id in my code.
How can I avoid this? What are the recommendations?
Thanks!
I overcome this by redirecting manually the ActionResult to an empty template with the following javascript autogen code:
public static string GetCanvasRedirectHtml(string url)
{
var fbApp = new FacebookApp();
string authUrl = string.Format("http://www.facebook.com/dialog/oauth?client_id={0}&redirect_uri={1}&scope={2}", fbApp.AppId, url, requiredAppPermissions);
if (string.IsNullOrEmpty(url))
{
throw new ArgumentNullException("url");
}
return "<html><head>" +
"<script type=\"text/javascript\">\n" +
"top.location = \"" + authUrl + "\";\n" +
"</script>" +
"</head><body></body></html>";
}
This would give me back the access_code that I would later on exchange for the accesstoken and get a valid session.
HTH someone!
精彩评论