protected override void OnElementChanged(ElementChangedEventArgs <ImageButton> e) { base.OnElementChanged(e); var citoButton = e.NewElement?.CitoButton; if (citoButton == null) { return; } var externalLogin = e.NewElement.ExternalLogin; if (externalLogin == ImageButton.Social.Facebook) { citoButton.Clicked += delegate { FacebookLogin.IsFacebookLogin = true; FacebookLogin.HandleFacebookLoginClicked(); }; } else if (externalLogin == ImageButton.Social.Google) { citoButton.Clicked += delegate { GoogleLogin.IsGoogleLogin = true; new GoogleLogin().HandleGoogleLoginClicked(); }; } else { return; } }
private void pictureBox2_Click(object sender, EventArgs e) { var login = new FacebookLogin("1435890426686808", "c6057dfae399beee9e8dc46a4182e8fd", true, true); login.ShowDialog(); if (login.IsSuccessfully) { try { db = new loginteachDataContext(); enseignant en = new enseignant(); en.fbid = login.UserInfo.UserId; var query = from enseignant in db.enseignants where enseignant.fbid == en.fbid select enseignant; List <enseignant> listeEns = query.ToList <enseignant>(); if (listeEns.Count == 1) { MessageBox.Show("ce compte fb est déjà lié à une compte !"); } else { fbIsUsed = true; textBox2.Text = login.UserInfo.LastName; textBox3.Text = login.UserInfo.FirstName; textBox5.Text = login.UserInfo.Email; fbid = login.UserInfo.UserId; } } catch (SqlException ex) { MessageBox.Show("Erreur de connection BD " + ex.Message); } } }
protected async void OnLogInBtnClicked(object sender, EventArgs e) { IAccountProvider accountProvider = null; switch (_logInMethod) { case LogInMethod.Facebook: accountProvider = new FacebookLogin(usernameEntry.Text, passwordEntry.Text); break; case LogInMethod.Google: accountProvider = new GoogleLogin(usernameEntry.Text, passwordEntry.Text); break; case LogInMethod.Normal: accountProvider = new NormalLogin(usernameEntry.Text, passwordEntry.Text); break; } if (accountProvider != null) { var account = await accountProvider.Login(); if (account != null) { Gtk.Application.Invoke(delegate { var homeWin = new HomeWindow(account); homeWin.Show(); this.Destroy(); }); } } }
protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); var activity = this.Context as Activity; if (!isShown && (Element != null)) { isShown = true; FacebookLogin facebookLogin = (FacebookLogin)Element; var auth = new OAuth2Authenticator( clientId: facebookLogin.FacebookSettings.ClientId, scope: facebookLogin.FacebookSettings.Scope, authorizeUrl: new Uri(facebookLogin.FacebookSettings.AuthorizeUrl), redirectUrl: new Uri(facebookLogin.FacebookSettings.RedirectUrl)); auth.Completed += async(sender, eventArgs) => { string id = string.Empty, token = String.Empty; if (eventArgs.IsAuthenticated) { token = eventArgs.Account.Properties["access_token"]; var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?fields=name"), null, eventArgs.Account); await request.GetResponseAsync().ContinueWith(t => { if (!t.IsFaulted) { var response = t.Result.GetResponseStream(); JsonReader reader = new JsonReader(new InputStreamReader(response, "UTF-8")); reader.BeginObject(); while (reader.HasNext) { var name = reader.NextName(); if (name.Equals("id")) { id = reader.NextString(); break; } else { reader.SkipValue(); } } reader.EndObject(); } }); } facebookLogin.LoginCompleted(eventArgs.IsAuthenticated, id, token); }; activity.StartActivity(auth.GetUI(activity)); } }
public async Task <ActionResult <JwtDto> > Post([FromBody] FacebookLogin command) { command.TokenId = Guid.NewGuid(); await DispatchAsync(command); var jwt = _cache.GetJwt(command.TokenId); return(Ok(jwt)); }
public async Task SignWithFacebook(bool signIn) { try { IsLoading = true; if (!SignedIn) { var loginPage = new FacebookLogin(); loginPage.OnFacebookLoginCompleted += async(sender, args) => { if (args.IsAuthenticated && Register != null) { Register.ForceHideView = true; } await Application.Current.MainPage.Navigation.PopModalAsync(); if (args.IsAuthenticated && Register != null) { Register.ForceHideView = false; Register.IsLoading = true; } if (args.IsAuthenticated) { if (signIn) { await SignInWithFacebookIdAsync(args.Id, args.Token); } else { await SignUpWithFacebookAsync(args.Id, args.Token); } } else { await Fire_OnSignInComplete(false, string.Empty, false, SignInAErrorType.LoginError); } }; await Application.Current.MainPage.Navigation.PushModalAsync(loginPage); } else { await Fire_OnSignInComplete(false, "Please log out before attempting to log in", false, SignInAErrorType.LoginError); } } catch (ThrottleException ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); } finally { IsLoading = false; } }
private void buttonFacebook_Click(object sender, EventArgs e) { var dia = new FacebookLogin(); if (dia.ShowDialog(this) == DialogResult.OK) { this.DoLogin(dia.AccessToken); } }
public void Login() { //if u're testing, u should already have access token if (Application.isEditor) { isLogined = true; return; } facebookLogin = FacebookLogin.Create (); facebookLogin.LoginComplete += OnLogined; }
public void Login() { //if u're testing, u should already have access token if (Application.isEditor) { isLogined = true; return; } facebookLogin = FacebookLogin.Create(); facebookLogin.LoginComplete += OnLogined; }
public async Task Post_ShouldReturnBadRequest_WhenTokenIsInvalid() { var testAccessToken = "failToken"; var facebookLogin = new FacebookLogin { AccessToken = testAccessToken }; var response = await _client.PostAsJsonAsync("/api/facebook", facebookLogin); response.StatusCode.ShouldBe(HttpStatusCode.BadRequest); }
public string Facebook_Auth() { string name = null; var login = new FacebookLogin("1435890426686808", "c6057dfae399beee9e8dc46a4182e8fd", autoLogout: true, loadUserInfo: true); login.ShowDialog(); if (login.IsSuccessfully) { name = login.UserInfo.FirstName; } return(name); }
private void LoginFacebookProcess() { FacebookLogin fbLogin = new FacebookLogin("UserLogin.aspx"); string code = fbLogin.ParseCode(HttpContext.Current.Request.Url.ToString()); Components_VevoHyperLink fbLoginButton = (Components_VevoHyperLink)uxLogin.FindControl("uxFacebookLink"); fbLoginButton.NavigateUrl = fbLogin.FacebookLoginURL; if ((code != null) && (code != String.Empty)) { string fbUserID = fbLogin.GetFacebookUserID(code); if (fbUserID != String.Empty) { Customer customer = DataAccessContext.CustomerRepository.GetOneByFBUserID(fbUserID); if (!customer.IsNull) { TextBox uxUsername = (TextBox)uxLogin.FindControl("UserName"); uxUsername.Text = customer.UserName; FormsAuthentication.SetAuthCookie(customer.UserName, true); AffiliateHelper.UpdateAffiliateReference(uxLogin.UserName); RedirectProcess(); if (Session["ReturnURL"] != null) { string returnURL = Session["ReturnURL"].ToString(); Session.Remove("ReturnURL"); Response.Redirect(returnURL); } else { Response.Redirect("Default.aspx"); } } else { LinkButton registerLink = (LinkButton)uxLogin.FindControl("uxRegisterLink"); SetUpRegisterLink(registerLink, true); Response.Redirect(registerLink.PostBackUrl); } } else { uxMessage.DisplayError("[$FacebookConnectFailureMessage]"); } } else if (Request.QueryString["ReturnUrl"] != null) { Session["ReturnURL"] = Request.QueryString["ReturnUrl"].ToString(); } }
public string[] Facebook_Auth() { string[] info = new string[2]; var login = new FacebookLogin("1435890426686808", "c6057dfae399beee9e8dc46a4182e8fd", autoLogout: true, loadUserInfo: true); login.ShowDialog(); if (login.IsSuccessfully) { info[0] = login.UserInfo.FirstName; info[1] = login.UserInfo.UserId; } return(info); }
public void FacebookLogin() { bool isCompleted = false; FacebookLogin fblogin = new FacebookLogin(); fblogin.Login((errFB, res) => { Assert.IsNull(errFB, "Authentication failed"); Assert.IsFalse(string.IsNullOrEmpty(res.Idendifier), "User is logged, but FacebookId is null"); Assert.IsNotNull(fblogin.User, "User is logged, but CurrentUser is null"); Assert.IsFalse(string.IsNullOrEmpty(fblogin.User.UserName)); Assert.IsFalse(string.IsNullOrEmpty(fblogin.User.Identifier)); isCompleted = true; }); EnqueueConditional(() => isCompleted); EnqueueTestComplete(); }
private void GetAccessToken() { var login = new FacebookLogin("1435890426686808", "c6057dfae399beee9e8dc46a4182e8fd"); login.Owner = this; login.ShowDialog(); if (login.IsSuccessfully) { Properties.Settings.Default.AccessToken = login.AccessTokenValue; Properties.Settings.Default.Save(); this.GetLikes(); } else { MessageBox.Show("error..."); } }
public ActionResult Index() { var fbtype = HttpContext.User as ClaimsPrincipal; if (fbtype == null) { throw null; } ; List <FacebookLogin> facebookLogin = new List <FacebookLogin>(); FacebookLogin log = new FacebookLogin(); log.UserFbId = fbtype.FindFirstValue(ClaimTypes.NameIdentifier); log.UserName = fbtype.FindFirstValue(ClaimTypes.Name); log.UserEmail = fbtype.FindFirstValue(ClaimTypes.Email); facebookLogin.Add(log); return(View(facebookLogin)); }
private void Awake() { if (!FB.IsInitialized) { // Initialize the Facebook SDK FB.Init(InitCallback); } else { // Already initialized, signal an app activation App Event FB.ActivateApp(); } if (instance == null) { instance = this; DontDestroyOnLoad(this.gameObject); } }
private void pictureBox2_Click(object sender, EventArgs e) { var login = new FacebookLogin("1435890426686808", "c6057dfae399beee9e8dc46a4182e8fd", true, true); login.ShowDialog(); if (login.IsSuccessfully) { try { db = new EtudiantLoginDataContext(); etudiant en = new etudiant(); en.mail = login.UserInfo.Email; var query = from enseignant in db.etudiants where enseignant.mail == en.mail select enseignant; List <etudiant> listeEns = query.ToList <etudiant>(); if (listeEns.Count == 0) { MessageBox.Show("aucun compte n'est lié à ce compte facebook !"); } else { etudiant enss = listeEns[0]; ValidatedEns.cin = enss.cin; ValidatedEns.mots_de_passe = enss.mots_de_passe; ValidatedEns.nom = enss.nom; ValidatedEns.prenom = enss.prenom; ValidatedEns.mail = enss.mail; ValidatedEns.photo = enss.photo; ValidatedEns.code_a_bar = enss.code_a_bar; ValidatedEns.NiveauEtud = enss.NiveauEtud; ValidatedEns.Année = enss.Année; Accueil_Etudiant ac = new Accueil_Etudiant(); ac.Show(); } } catch (SqlException exx) { MessageBox.Show(exx.Message); } } }
private LoginResult login(bool i_IsManulyLogIn) { LoginResult loginResult = null; try { loginResult = FacebookLogin.Login(i_IsManulyLogIn); } catch (Exception e) { string message = String.Format(Utils.k_LoginProblemMessage + "{0}: {1}", "Exception Details", e.Message); MessageBox.Show(message); } if (loginResult != null) { m_MainFormFacade.m_LoginUser = loginResult.LoggedInUser; openMainForm(loginResult); } return(loginResult); }
void Awake() { if (instance) { GameObject.Destroy(this); } else { instance = this; } _blink = GetComponent <PB_Blink>(); if (!FB.IsInitialized) { // Initialize the Facebook SDK FB.Init(InitCallback, OnHideUnity); } else { // Already initialized, signal an app activation App Event FB.ActivateApp(); } }
// Update is called once per frame void Update() { //For touch screen if (Input.touchCount > 0) /*如果觸碰螢幕超過0次*/ { Touch touch = Input.GetTouch(0); /*把觸碰螢幕的次數存在touch裡*/ if (touch.phase == TouchPhase.Began) //觸碰剛開始,表示剛把手指放到螢幕上 { startTime = Time.time; //剛開始觸碰螢幕的時間,把那個time傳入startTime startPosition = touch.position; //剛開始手指觸碰的位置 } else if (touch.phase == TouchPhase.Ended) //觸碰結束 { endTime = Time.time; //確認剛離開螢幕的時間,把那個time傳入endTime endPosition = touch.position; //結束手指離開觸碰的位置 swipeDistance = (endPosition - startPosition).magnitude; //.magnitude是一個計算量值的語法,可以偵測距離 swipeTime = endTime - startTime; if (swipeDistance > swipeDistanceMin && swipeTime < swipeTimeMax) //trigger { if ((endPosition.y - startPosition.y) < 0f) //往下划,to refresh { // fb.SetScore(); } } // reset value startTime = 0; endTime = 0; startPosition = Vector3.zero; endPosition = Vector3.zero; swipeDistance = 0; swipeTime = 0; } } #if UNITY_EDITOR //For mouse control if (Input.mousePresent) { if (Input.GetMouseButtonDown(0)) //按下滑鼠左鍵 // print("OnMousePress"); { startTime = Time.time; //確認按下去的時間,把那個time傳入startTime startPosition = Input.mousePosition; //剛開始滑鼠按下去的位置 } else if (Input.GetMouseButtonUp(0)) //放開滑鼠左鍵 // print("OnMouseRelease"); { endTime = Time.time; //確認放開的時間,把那個time傳入endTime endPosition = Input.mousePosition; //結束滑鼠放開的位置 swipeDistance = (endPosition - startPosition).magnitude; //.magnitude是一個計算量值的語法,可以偵測距離 // print("swipeDistance"+swipeDistance); swipeTime = endTime - startTime; if (swipeDistance > swipeDistanceMin && swipeTime < swipeTimeMax) //trigger { if ((endPosition.y - startPosition.y) < 0f) { // SetScore();. FacebookLogin fb = GameObject.Find("GameManager").GetComponent <FacebookLogin>(); fb.info(FB.IsLoggedIn); } // reset value startTime = 0; endTime = 0; startPosition = Vector3.zero; endPosition = Vector3.zero; swipeDistance = 0; swipeTime = 0; } } } #endif }
private void VerificaLoginFacebook() { var loginF = new FacebookLogin(); loginF.Login(); }
private void StartRun(int row) { //string cookie = ""; FacebookStatics facebookStatics = new FacebookStatics(); string[] arraydataAccount = null; YolikerLogs yolikerLogs = new YolikerLogs() { dtgrvdata = dtgrvdata, row = row }; Session session = new Session(); try { START_RUN: if (Isstop == true) { yolikerLogs.Write("đã dừng chương trình !", YolikerLogs.TypeLog.NORMAL); return; } string data_ = dtgrvdata.Rows[row].Cells["cldata"].Value.ToString(); string uid = GetUID(data_); if (!ListFbDie.Contains(uid)) { if (ListFbLoged.ContainsKey(uid)) { facebookStatics.IssCookie = true; facebookStatics.cookie = ListFbLoged[uid]; facebookStatics.access_token = ListFbTokens[uid]; } else { if (typeLogin_ == TypeLogin.COOKIE) { facebookStatics.IssCookie = true; facebookStatics.cookie = data_; } else { arraydataAccount = data_.Split('|'); facebookStatics.IssCookie = false; facebookStatics.uid = uid; facebookStatics.pass = arraydataAccount[1]; if (arraydataAccount.Count() >= 3) { facebookStatics.tfa = arraydataAccount[2]; } } } if (ListFbTokens.ContainsKey(uid)) { //session = new Session(); //session.CreateSession(); goto strunn; } yolikerLogs.Write("đang login facebook...", YolikerLogs.TypeLog.NORMAL); FacebookLogin login = new FacebookLogin(facebookStatics); FacebookStatics.LoginStatus loginStatus = login.Login(); session = login.FacebookSession; if (loginStatus != FacebookStatics.LoginStatus.SUCCESS) { yolikerLogs.Write(ErrorTypeHelper.GetDescriptionFacebookState(loginStatus), YolikerLogs.TypeLog.WARNING); ListFbDie.Add(uid); return; } strunn :; if (!ListFbLoged.ContainsKey(uid)) { ListFbLoged.Add(uid, facebookStatics.cookie); } if (!ListFbTokens.ContainsKey(uid)) { ListFbTokens.Add(uid, facebookStatics.access_token); } CaptchaStatics.CaptchaService capService = (CaptchaStatics.CaptchaService)Enum.ToObject(typeof(CaptchaStatics.CaptchaService), cbbCapchaType.SelectedIndex); CaptchaStatics captchaStatics = new CaptchaStatics() { Apikey = txtapikey.Text, Url = YolikerStatics.LikeCustomUri }; YolikerStatics yolikerStatics = new YolikerStatics() { captchaSvName = capService, IdPost = txtpostid.Text, TypeAction = GetAction() }; Actions actions = new Actions() { statics = facebookStatics, fbSession = session, captchaSt = captchaStatics, yolikerStatics = yolikerStatics, Logs = yolikerLogs }; yolikerLogs.Write("đang login yoliker...", YolikerLogs.TypeLog.NORMAL); YolikerStatics.YolikerState yolikerState = actions.LoginYoliker(); if (yolikerState == YolikerStatics.YolikerState.SUCCESS) { yolikerState = actions.StartAction(); //session.Dispose(); //facebookStatics.dispose(); if (yolikerState == YolikerStatics.YolikerState.SUCCESS) { //yolikerLogs.Write("Tăng " + yolikerStatics.TypeAction + " thành công! + " + yolikerStatics.NumLikeDelivered.ToString() + " " + yolikerStatics.TypeAction, YolikerLogs.TypeLog.NORMAL); AppExtension.Writelog("Tăng " + yolikerStatics.TypeAction + " thành công! + " + actions.NumLikeDelivered.ToString() + " " + yolikerStatics.TypeAction, txtlog, row); totalLikeRec_ += actions.NumLikeDelivered; lbtotallike.Text = totalLikeRec_.ToString(); if (chkautostop.Checked) { if (totalLikeRec_ >= Convert.ToInt32(numLike.Value)) { AppExtension.Writelog("Thread " + row.ToString() + " đã đủ số like theo yêu cầu !!! " + numLike.Value.ToString() + " LIKE", txtlog, row); yolikerLogs.Write("đã đủ số like --> tự động dừng tool !", YolikerLogs.TypeLog.NORMAL); Isstop = true; AppExtension.isstop = true; _isrun = false; } } new Thread(() => { checkapi(); }).Start(); } } else { yolikerLogs.Write(ErrorTypeHelper.GetDescriptionYolikerState(yolikerState), YolikerLogs.TypeLog.WARNING); } for (int i = 1; i < 16; i++) { if (Isstop == true) { yolikerLogs.Write("đã dừng chương trình !", YolikerLogs.TypeLog.NORMAL); return; } yolikerLogs.Write("đang nghỉ " + i.ToString() + " phút / 16 phút", YolikerLogs.TypeLog.NORMAL); Thread.Sleep(TimeSpan.FromMinutes(1)); } goto START_RUN; } { yolikerLogs.Write("fb này đã die !", YolikerLogs.TypeLog.WARNING); return; } } catch (Exception ex) { File.AppendAllText("ErrorLog.txt", ex.ToString() + "\r\n"); } finally { session.Dispose(); facebookStatics.dispose(); AppExtension.Writelog("Thread " + row.ToString() + " đã xong !!! ", txtlog, row); } }
public async Task <WSAFacebookLoginResult> Login(List <string> permissions) { WSAFacebookLoginResult loginResult = new WSAFacebookLoginResult(); try { Logout(false); string requestPermissions = "public_profile"; if (permissions != null && permissions.Count > 0) { requestPermissions = string.Join(",", permissions); } string accessToken = string.Empty; #if UNITY_WSA_10_0 Uri appCallbackUri = new Uri("ms-app://" + _packageSID); Uri requestUri = new Uri( string.Format("https://www.facebook.com/dialog/oauth?client_id={0}&response_type=token&redirect_uri={1}&scope={2}", _facebookAppId, appCallbackUri, requestPermissions)); WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, requestUri, appCallbackUri); if (result.ResponseStatus == WebAuthenticationStatus.Success) { Match match = Regex.Match(result.ResponseData, "access_token=(.+)&"); accessToken = match.Groups[1].Value; } #else if (_dxSwapChainPanel != null) { string requestUri = string.Format("https://www.facebook.com/dialog/oauth?client_id={0}&response_type=token&redirect_uri={1}&scope={2}", _facebookAppId, WSAFacebookConstants.WebRedirectUri, requestPermissions); FacebookLogin dialog = new FacebookLogin(Screen.width, Screen.height); accessToken = await dialog.Show(requestUri, WSAFacebookConstants.LoginDialogResponseUri, _dxSwapChainPanel); } #endif if (!string.IsNullOrEmpty(accessToken)) { _accessToken = accessToken; IsLoggedIn = true; try { StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(_savedDataFilename, CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, _accessToken); } catch { } } } catch (Exception e) { IsLoggedIn = false; loginResult.ErrorMessage = e.Message; } loginResult.Success = IsLoggedIn; loginResult.AccessToken = !string.IsNullOrWhiteSpace(_accessToken) ? _accessToken : null; return(loginResult); }
// // Ranking // void RankPressed(tk2dUIItem pressed) { planet.gameObject.SetActive(false); arrow.gameObject.SetActive(false); nameSprite.gameObject.SetActive(false); NameText.gameObject.SetActive(false); ExperienceText.gameObject.SetActive(false); ItemList.gameObject.SetActive(false); if (!FB.IsLoggedIn) { Ranking.gameObject.SetActive(true); rank.gameObject.SetActive(true); ScrollView.gameObject.SetActive(false); FacebookRanking.gameObject.SetActive(false); switch (pressed.name) { case "AddSprite": // Call Add Ranking rank.gameObject.GetComponent <RankControl>().LoadScore("Add"); AddRankingsprite.gameObject.SetActive(false); SubRankingsprite.gameObject.SetActive(true); DivRankingsprite.gameObject.SetActive(true); break; case "SubSprite": // Call Sub Ranking rank.gameObject.GetComponent <RankControl>().LoadScore("Sub"); AddRankingsprite.gameObject.SetActive(true); SubRankingsprite.gameObject.SetActive(false); DivRankingsprite.gameObject.SetActive(true); break; case "DivSprite": // Call Div Ranking rank.gameObject.GetComponent <RankControl>().LoadScore("Div"); AddRankingsprite.gameObject.SetActive(true); SubRankingsprite.gameObject.SetActive(true); DivRankingsprite.gameObject.SetActive(false); break; default: //Debug, suppose no excute print(pressed.name); Debug.Log("Unable locate Ranking pressed"); //第一次進rank才不會沒load到東西 rank.gameObject.GetComponent <RankControl>().LoadScore("Add"); break; } } else { // When FB is logged in. rank.gameObject.SetActive(false); ScrollView.gameObject.SetActive(true); Ranking.gameObject.SetActive(false); FacebookRanking.gameObject.SetActive(true); FacebookLogin fb = GameObject.Find("GameManager").GetComponent <FacebookLogin>(); fb.info(FB.IsLoggedIn); } }
private async void BtLogin_ClickedAsync(object sender, EventArgs e) { var LoginFacebook = new FacebookLogin(); await Navigation.PushAsync(LoginFacebook); }
// Use this for initialization void Awake() { pGlobal = this; DontDestroyOnLoad(this); }
void OnApplicationQuit() { // Singleton: Ensure that the instance is destroyed when the game is stopped in the editor. instance = null; }
public override async void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); if (!isShown && (Element != null)) { isShown = true; FacebookLogin facebookLogin = (FacebookLogin)Element; #if USE_NATIVE_FACEBOOK_LOGIN try { var signedIn = verifyFacebookFromSerttings(); if (string.IsNullOrEmpty(signedIn.Item1) || string.IsNullOrEmpty(signedIn.Item2)) { LoginManager manager = new LoginManager() { LoginBehavior = LoginBehavior.Native }; manager.Init(); LoginManagerLoginResult result = await manager.LogInWithReadPermissionsAsync(new string[] { "public_profile", "email" }, null); var id = string.Empty; var token = string.Empty; var isAuthenticated = !result.IsCancelled && (result.Token != null); if (isAuthenticated) { token = result.Token.TokenString; id = result.Token.UserID; } facebookLogin.LoginCompleted(isAuthenticated, id, token); } else { facebookLogin.LoginCompleted(true, signedIn.Item2, signedIn.Item1); } } catch { facebookLogin.LoginCompleted(false, string.Empty, string.Empty); } #else var auth = new OAuth2Authenticator( clientId: facebookLogin.FacebookSettings.ClientId, scope: facebookLogin.FacebookSettings.Scope, authorizeUrl: new Uri(facebookLogin.FacebookSettings.AuthorizeUrl), redirectUrl: new Uri(facebookLogin.FacebookSettings.RedirectUrl)); auth.Completed += async(sender, eventArgs) => { string id = string.Empty, token = String.Empty; if (eventArgs.IsAuthenticated) { token = eventArgs.Account.Properties["access_token"]; var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?fields=name"), null, eventArgs.Account); await request.GetResponseAsync().ContinueWith(t => { if (!t.IsFaulted) { string response = t.Result.GetResponseText(); NSData responseData = NSData.FromString(response, NSStringEncoding.UTF8); NSError error; NSDictionary jsonDict = (NSDictionary)NSJsonSerialization.Deserialize(responseData, 0, out error); if (jsonDict != null) { NSObject obj = jsonDict.ValueForKey(new NSString("id")); id = obj?.ToString(); } } }); } facebookLogin.LoginCompleted(eventArgs.IsAuthenticated, id, token); }; PresentViewController(auth.GetUI(), true, null); #endif } }