Trying to open Request for permission in a popup
I'm using the facebook C# SDK version 5.0.10. When I logon myself I don't understand why the "Request for Permission" interface is opened in a tab instead of in a new popup.
Here is my code:
var parameters = new Dictionary<string, object>
{
{ "response_type", "token" },
{ "display", "popup" },
{ "state", returnUrl },
{ "scope", scope.ToString() },
};
[...]
var loginUri = oAuthClient.GetLoginUrl(parameters);
Does anybody have an idea开发者_高级运维 ?
I also use C# SDK 5.0.10. I suggest to download the samples (FacebookSDK-5.0.10.0-41e55d6506e.src.zip) and check the samle called "CSASPNETFacebookApp".
I used the same technique of that sample and for me, the permissions don't open in a new tab or a new popup, but even better: in the same page. When you grant the permissions you will be automatically redirected to the App page you were trying to access. Very practical. With a few lines of code you can get the authentication working.
For the redirect, make sure to have in the web.config the handler:
<httpHandlers>
<add verb="*" path="facebookredirect.axd" type="Facebook.Web.FacebookAppRedirectHttpHandler, Facebook.Web"/>
</httpHandlers>
If you want the popup, then you have to use fbml (in the html/aspx page):
<fb:login-button onlogin="document.location.href=document.location.href;" perms="publish_stream">Grant Permissions</fb:login-button>
When you click the "Grant Permissions" button a popup with the permissions request will be opened.
Hope this helps.
精彩评论