Created
May 25, 2014 09:54
-
-
Save Tapanila/51b52286b6a9d7251a74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public FacebookLogin(Panel container, Page page) | |
| { | |
| _page = page; | |
| //Initialize _webBrowser | |
| _webBrowser = new WebBrowser(); | |
| //Get this from the facebook | |
| string appId = ""; | |
| //List of all the permissions you want to have access to | |
| //You can get the list of possiblities from here | |
| //http://developers.facebook.com/tools/explorer/ | |
| string[] extendedPermissions = new[] { | |
| "publish_stream", | |
| "offline_access", | |
| "user_groups", | |
| "user_photos"; | |
| }; | |
| var oauth = new FacebookOAuthClient { AppId = appId }; | |
| //Telling the Facebook that we want token as response | |
| //and we are using touch enabled device | |
| var parameters = new Dictionary<string, object> | |
| { | |
| { "response_type", "token" }, | |
| { "display", "touch" } | |
| }; | |
| //If there's extended permissions build the string | |
| //and set it up | |
| if (extendedPermissions != null && | |
| extendedPermissions.Length > 0) | |
| { | |
| var scope = new StringBuilder(); | |
| scope.Append(string.Join(",", extendedPermissions)); | |
| parameters["scope"] = scope.ToString(); | |
| } | |
| //Create the login url | |
| var loginUrl = oauth.GetLoginUrl(parameters); | |
| //Add webBrowser to the contentPanel | |
| container.Children.Add(_webBrowser); | |
| _webBrowser.Navigated += webBrowser_Navigated; | |
| //Open the facebook login page into the browser | |
| _webBrowser.Navigate(loginUrl); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment