private void AuthCallback(ILoginResult result) { if (FB.IsLoggedIn) { // AccessToken class will have session details var aToken = AccessToken.CurrentAccessToken; // Print current access token's User Credential credential = FacebookAuthProvider.GetCredential(aToken.TokenString); user.LinkWithCredentialAsync(credential).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithCredentialAsync was canceled."); return; } if (task.IsFaulted) { auth.SignOut(); Debug.Log("Called1"); auth.SignInWithCredentialAsync(credential).ContinueWith(task2 => { if (task2.IsCanceled) { return; } if (task2.IsFaulted) { return; } if (task2.IsCompleted) { reference.Child("users").Child(deviceID).Child("online").SetValueAsync("false"); user = task2.Result; reload = true; } }); } else if (task.IsCompleted) { Debug.Log("Logged In"); user = task.Result; localUser = new User(userNametext, user.Email, aToken.UserId, user.UserId); writeNewUser(user.UserId, userNametext, user.Email, aToken.UserId); } }); } else { Debug.Log("User cancelled login"); } }
public async Task <IAuthResult> LinkWithCredentialAsync(IAuthCredential credential) { try { var result = await _user.LinkWithCredentialAsync(credential.ToNative()).ConfigureAwait(false); return(new AuthResultWrapper(result)); } catch (FirebaseException e) { throw ExceptionMapper.Map(e); } }