private void LoginButtonOnCompleted(object sender, LoginButtonCompletedEventArgs loginButtonCompletedEventArgs) { if (loginButtonCompletedEventArgs.Error != null || loginButtonCompletedEventArgs.Result.IsCancelled) { return; } AccessToken.CurrentAccessToken = loginButtonCompletedEventArgs.Result.Token; GraphRequestProfile(loginButtonCompletedEventArgs.Result.Token.UserID); }
void LoginView_Completed(object sender, LoginButtonCompletedEventArgs e) { if (e.Error != null) { // Handle if there was an error LoadingOverlay.RemoveOverlay(); Console.WriteLine("There was an error. Please, try again later"); DisplayAlertMessage("There was an error. Please, try again later"); return; } if (e.Result.IsCancelled) { return; // Handle if the user cancelled the login request } }
private void LoginView_Completed(object sender, LoginButtonCompletedEventArgs e) { if (e != null) { if (e.Error != null) { //UNDONE: Handle if there was an error } if (e.Result.IsCancelled) { //UNDONE: Handle if the user cancelled the login request } } //UNDONE: Handle your successful login //do nothing }
void AuthCompleted(object sender, LoginButtonCompletedEventArgs args) { var view = (this.Element as FacebookLoginButton); if (args.Error != null) { // Handle if there was an error view.OnError?.Execute(args.Error.ToString()); } else if (args.Result.IsCancelled) { // Handle if the user cancelled the login request view.OnCancel?.Execute(null); } else { // Handle your successful login view.OnSuccess?.Execute(args.Result.Token.TokenString); } }
void BtnLogin_Completed(object sender, LoginButtonCompletedEventArgs e) { if (e.Error != null) { // Handle if there was an error AppDelegate.ShowMessage("Could not login!", e.Error.Description, NavigationController); return; } if (e.Result.IsCancelled) { // Handle if the user cancelled the login request AppDelegate.ShowMessage("Could not login!", "The user cancelled the login", NavigationController); return; } // Get access token for the signed-in user and exchange it for a Firebase credential var credential = FacebookAuthProvider.GetCredential(AccessToken.CurrentAccessToken.TokenString); // Authenticate with Firebase using the credential Auth.DefaultInstance.SignIn(credential, SignInOnCompletion); }
#endregion LogIn with Email public void FacebookLoginProcess(LoginButtonCompletedEventArgs e) { if (e.Error != null) { Console.WriteLine(e.Error.ToString()); new UIAlertView("Facebook", "We were not able to authenticate you with Facebook. Please login again.", null, "OK", null) .Show(); } else if (e.Result.IsCancelled) { Console.WriteLine("Result was cancelled"); new UIAlertView("Facebook", "You cancelled the Facebook login process. Please login again.", null, "OK", null).Show(); } else if (!e.Result.GrantedPermissions.ToString().Contains("email")) { // Check that we have email as a permission, otherwise show that we can't signup Console.WriteLine("Email permission not found"); new UIAlertView("Facebook", "Email permission is required to sign in, Please login again.", null, "OK", null).Show(); } else { var meRequest = new GraphRequest("/me", new NSDictionary("fields", "first_name,last_name,name,email,picture"), "GET"); var requestConnection = new GraphRequestConnection(); requestConnection.AddRequest(meRequest, (connection, meResult, meError) => { var client = new WebClient(); if (meError != null) { Console.WriteLine(meError.ToString()); new UIAlertView("Facebook", "Unable to login to facebook.", null, "OK", null).Show(); return; } var user = meResult as NSDictionary; var sc = new SocialLoginData(); sc.scFirstName = user.ValueForKey(new NSString("first_name")).Description; sc.scLastName = user.ValueForKey(new NSString("last_name")).Description; sc.scUserName = user.ValueForKey(new NSString("name")).Description; sc.scSocialId = user.ValueForKey(new NSString("id")).Description; sc.scEmail = user.ValueForKey(new NSString("email")).Description; sc.scProfileImgUrl = ""; //user.ValueForKey(new NSString("picture")).Description; sc.scSource = "facebook"; sc.scAccessUrl = "http://facebook.com/profile.php?id=" + user.ValueForKey(new NSString("id")).Description; sc.scSocialOauthToken = AccessToken.CurrentAccessToken.TokenString; sc.scAccount = AccessToken.CurrentAccessToken.TokenString; StartRegistration(sc); }); requestConnection.Start(); } } public async void StartRegistration(SocialLoginData SocialData) { InpowerResult Result = null; UserProfile userProfile = new UserProfile(); try { string isscEmail = ""; if (SocialData.scEmail != "" || SocialData.scEmail != null) { isscEmail = SocialData.scEmail; }else{isscEmail = SocialData.scFirstName + SocialData.scLastName + SocialData.scSocialId + "@InPower.com";} Result = await new AccountService().Registration(new UserRegisterRequestViewModel { FirstName = SocialData.scFirstName, LastName = SocialData.scLastName, Email = isscEmail , Password = "******" }, GlobalConstant.AccountUrls.RegisterServiceUrl); var modelReporeg = JsonConvert.DeserializeObject<UserRegisterResponseViewModel>(Result.Response.ToString()); var ResultToken = await new AccountService().AccessToken(new TokenRequestViewModel { UserName = modelReporeg.Email, password = modelReporeg.Password, grant_type = "password" }); if (Result.Message == "Detail Successfully Updated") { ContinuetoMainScreen(modelReporeg.UserId.ToString(), modelReporeg.Password, ResultToken.access_token, modelReporeg.Email, modelReporeg.AWSAccessKey,modelReporeg.AWSSecretKey); } else { var token = AccessToken.CurrentAccessToken != null; if (ResultToken != null) {
private void LoginButton_Completed(object sender, LoginButtonCompletedEventArgs e) { var result = e.Result; }