Ejemplo n.º 1
0
    public static void GoogleAuth(string GoogleTokenID, string GoogleAccessToken)
    {
        Credential Credential = GoogleAuthProvider.GetCredential(GoogleTokenID, GoogleAccessToken);

        Auth.SignInWithCredentialAsync(Credential).ContinueWith(Task =>
        {
            if (Task.IsCanceled)
            {
                Debug.LogError("Firebase Auth - SignInWithCredentialAsync foi cancelado.");
                TecWolf.System.SystemInterface.Alert("O login da conta foi cancelado.");
                return;
            }
            if (Task.IsFaulted)
            {
                Debug.LogError("Firebase Auth - SignInWithCredentialAsync encontrou um erro: " + Task.Exception);
                TecWolf.System.SystemInterface.Alert("Erro ao logar conta, verifique Email e Senha.");
                return;
            }

            User = Task.Result;

            Debug.LogFormat("Firebase Auth - Usuário logado com sucesso: {0} ({1})", User.DisplayName, User.UserId);
            TecWolf.System.SystemInterface.Alert("Conta logada com sucesso.");
        });
    }
Ejemplo n.º 2
0
    /*
     * private void OnLogIn(ILoginResult result)
     * {
     *  if (FB.IsLoggedIn)
     *  {
     *      AccessToken tocken = AccessToken.CurrentAccessToken;
     *      userID.text = tocken.UserId;
     *      Credential credential = FacebookAuthProvider.GetCredential(tocken.TokenString);
     *  }
     *  else
     *      Debug.Log("log failed");
     * }*/

    public void AccessTokenN(Credential firebaseResult)
    {
        //FirebaseAuth auth = FirebaseAuth.DefaultInstance;  borrado hoy

        //if (FB.IsLoggedIn)
        //  return;

        auth.SignInWithCredentialAsync(firebaseResult).ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInWithCredentialAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                return;
            }

            FirebaseUser newUser = task.Result;
            Debug.LogFormat("User signed in successfully: {0} ({1})",
                            newUser.DisplayName, newUser.UserId);
        });
    }
Ejemplo n.º 3
0
    public void GoogleLoginProcessing()
    {
        if (GoogleSignIn.Configuration == null)
        {
            // 설정
            GoogleSignIn.Configuration = new GoogleSignInConfiguration
            {
                RequestIdToken = true,
                RequestEmail   = true,
                // Copy this value from the google-service.json file.
                // oauth_client with type == 3
                WebClientId = "941687707302-gtlgk8ujs4ksg0ijnndjd0do6k33ljve.apps.googleusercontent.com"
            };
        }

        Task <GoogleSignInUser> signIn = GoogleSignIn.DefaultInstance.SignIn();

        TaskCompletionSource <FirebaseUser> signInCompleted = new TaskCompletionSource <FirebaseUser>();

        signIn.ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.Log("Google Login task.IsCanceled");
            }
            else if (task.IsFaulted)
            {
                Debug.Log("Google Login task.IsFaulted");
            }
            else
            {
                Credential credential = Firebase.Auth.GoogleAuthProvider.GetCredential(((Task <GoogleSignInUser>)task).Result.IdToken, null);
                auth.SignInWithCredentialAsync(credential).ContinueWith(authTask =>
                {
                    if (authTask.IsCanceled)
                    {
                        signInCompleted.SetCanceled();
                        Debug.Log("Google Login authTask.IsCanceled");
                        return;
                    }
                    if (authTask.IsFaulted)
                    {
                        signInCompleted.SetException(authTask.Exception);
                        Debug.Log("Google Login authTask.IsFaulted");
                        return;
                    }

                    // The user's Id, unique to the Firebase project.
                    // Do NOT use this value to authenticate with your backend server, if you
                    // have one; use User.TokenAsync() instead.
                    user = authTask.Result;
                    Debug.LogFormat("Google User signed in successfully: {0} ({1})", user.DisplayName, user.UserId);
                    return;
                });
            }
        });
    }
Ejemplo n.º 4
0
 // This is functionally equivalent to the Signin() function.  However, it
 // illustrates the use of Credentials, which can be aquired from many
 // different sources of authentication.
 public Task SigninWithEmailCredentialAsync()
 {
     DebugLog(string.Format("Attempting to sign in as {0}...", email));
     DisableUI();
     if (signInAndFetchProfile)
     {
         return(auth.SignInAndRetrieveDataWithCredentialAsync(
                    EmailAuthProvider.GetCredential(email, password)).ContinueWith(
                    HandleSignInWithSignInResult));
     }
     return(auth.SignInWithCredentialAsync(
                EmailAuthProvider.GetCredential(email, password)).ContinueWith(
                HandleSignInWithUser));
 }
 public void SignInWithFacebook(string accessToken, Action <FirebaseUserResult> callback)
 {
     if ((Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) && !Application.isEditor)
     {
         Credential credential = FacebookAuthProvider.GetCredential(accessToken);
         targetBehaviour.StartCoroutine(ProcessFirebaseUserTaskRoutine(auth.SignInWithCredentialAsync(credential), callback));
     }
     else
     {
         WWWForm form = new WWWForm();
         form.AddField("access_token", accessToken);
         WWW www = new WWW(serviceUrl + "/signInWithFacebook", form);
         targetBehaviour.StartCoroutine(ProcessWebServiceUserRoutine(www, callback));
     }
 }
Ejemplo n.º 6
0
    public Task <FirebaseUser> SignInUserWithFacebook(string accessToken)
    {
        Credential credential = FacebookAuthProvider.GetCredential(accessToken);

        if (auth.CurrentUser != null)
        {
            Task <FirebaseUser> task = auth.CurrentUser.LinkWithCredentialAsync(credential);
            task.ContinueWith(t =>
            {
                if (t.IsCanceled)
                {
                    Debug.Log("LinkWithCredentialAsync was canceled.");
                }
                if (t.IsFaulted)
                {
                    Debug.Log("LinkWithCredentialAsync encountered an error: " + t.Exception);
                }

                Firebase.Auth.FirebaseUser newUser = t.Result;
                Debug.LogFormat("Credentials successfully linked to Firebase user: {0} ({1})",
                                newUser.DisplayName, newUser.UserId);
            });
            return(task);
        }
        else
        {
            Task <FirebaseUser> task = auth.SignInWithCredentialAsync(credential);

            task.ContinueWith(t =>
            {
                if (t.IsCanceled)
                {
                    Debug.Log("SignInWithCredentialAsync was canceled.");
                    return;
                }
                if (t.IsFaulted)
                {
                    Debug.Log("SignInWithCredentialAsync encountered an error: " + task.Exception);
                    return;
                }

                Firebase.Auth.FirebaseUser newUser = t.Result;
                Debug.LogFormat("User signed in successfully: {0} ({1})",
                                newUser.DisplayName, newUser.UserId);
            });
            return(task);
        }
    }
Ejemplo n.º 7
0
    IEnumerator TryFirebaseLogin()
    {
        while (string.IsNullOrEmpty(((PlayGamesLocalUser)Social.localUser).GetIdToken()))
        {
            yield return(null);
        }
        string idToken = ((PlayGamesLocalUser)Social.localUser).GetIdToken();

        Credential credential = GoogleAuthProvider.GetCredential(idToken, null);

        auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
        {
            if (task.IsCompleted && !task.IsCanceled && !task.IsFaulted)
            {
                FirebaseUser newUser      = task.Result;
                PlayerInformation.auth    = auth;
                PlayerInformation.isLogin = true;
                DatabaseManager.SetNewUserData();
                DatabaseManager.UpdateMoney(0);
                DatabaseManager.GetScore(true);  // hard
                DatabaseManager.GetScore(false); // easy

                //PlayerInformation.BestScore = DatabaseManager.GetScore(true);
                //PlayerInformation.EasyBestScore = DatabaseManager.GetScore(false);

                storeManager.InitStoreAsync();
                storeManager.InitFaceCharge();
                storeManager.InitBoatCharge();
                storeManager.InitWaveCharge();
                menuManager.SetDestination();
            }
        });
    }
Ejemplo n.º 8
0
    public async void VincularUsuarioAnonimo()
    {
        if (auth.CurrentUser.IsAnonymous == true)
        {
            PreCadastro();

            Credential credential = EmailAuthProvider.GetCredential(email.text, senha.text);

            await auth.CurrentUser.LinkWithCredentialAsync(credential).ContinueWith(task =>
            {
            });

            await auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
            {
            });

            if (auth.CurrentUser.IsAnonymous == false)
            {
                ReenviarEmailVerificacaoAnonimo();
            }
            else
            {
                Debug.Log("Verifique se o email digitado já não possui cadastro ou a senha está fora dos requisitos.");
                PosCadastro();
            }
        }
    }
Ejemplo n.º 9
0
    IEnumerator TryFirebaseLogin()
    {
        while (string.IsNullOrEmpty(((PlayGamesLocalUser)Social.localUser).GetIdToken()))
        {
            yield return(null);
        }
        string idToken = ((PlayGamesLocalUser)Social.localUser).GetIdToken();


        Credential credential = GoogleAuthProvider.GetCredential(idToken, null);

        auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInWithCredentialAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                return;
            }

            FirebaseUser newUser = task.Result;
            Debug.LogFormat("User signed in successfully: {0} ({1})",
                            newUser.DisplayName, newUser.UserId);
            //loginResult.text = " 구글 로그인 굿럭";

            Debug.Log("Success!");
        });
    }
Ejemplo n.º 10
0
    IEnumerator TryFirebaseLogin()
    {
        while (string.IsNullOrEmpty(((PlayGamesLocalUser)Social.localUser).GetIdToken()))
        {
            yield return(null);
        }
        string idToken = ((PlayGamesLocalUser)Social.localUser).GetIdToken();

        Credential credential = GoogleAuthProvider.GetCredential(idToken, null);

        auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInWithCredentialAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                return;
            }
            auth = FirebaseAuth.DefaultInstance;
            googleText.SetActive(false);
            ranking.SetActive(true);
            LogOut.SetActive(true);
            user = auth.CurrentUser;
            SingletonManager.uID = user.UserId;
        });
    }
Ejemplo n.º 11
0
    public void FacebookSignedIn(string accessToken, Action callback = null)
    {
        Credential credential =
            FacebookAuthProvider.GetCredential(accessToken);

        auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInWithCredentialAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                return;
            }

            Firebase.Auth.FirebaseUser newUser = task.Result;
            Debug.LogFormat("User signed in successfully: {0} ({1})",
                            newUser.DisplayName, newUser.UserId);
            if (callback != null)
            {
                callback();
            }
        });
    }
Ejemplo n.º 12
0
        private void OnFacebookLogin(ILoginResult result)
        {
            if (FB.IsLoggedIn)
            {
                var token      = AccessToken.CurrentAccessToken.TokenString;
                var credential = FacebookAuthProvider.GetCredential(token);

                _showLoading.Raise();

                _auth.SignInWithCredentialAsync(credential).ContinueWith(OnFacebookAuthenticationFinished);
            }
            else
            {
                Utils.ShowMessage("Login Failed");
            }
        }
Ejemplo n.º 13
0
    private void SignInWithGoogleOnFirebase(string idToken)
    {
        Credential credential = GoogleAuthProvider.GetCredential(idToken, null);

        auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
        {
            AggregateException ex = task.Exception;
            if (ex != null)
            {
                if (ex.InnerExceptions[0] is FirebaseException inner && (inner.ErrorCode != 0))
                {
                    AddToInformation("\nError code: " + inner.ErrorCode + " Message: " + inner.Message);
                    ViewMessageOnScreen("\nError code: " + inner.ErrorCode + " Message: " + inner.Message);
                }
                else
                {
                    loadDashboard              = true;
                    Globals.username           = task.Result.DisplayName;
                    Globals.email              = task.Result.Email;
                    Globals.userId             = task.Result.UserId;
                    Globals.isLoggedIn         = true;
                    Globals.loggedInWithGoogle = true;
                    AddToInformation("SignIn Successful ... ");
                }
            }
        });
Ejemplo n.º 14
0
    IEnumerator TryFirebaseLogin()
    {
        while (string.IsNullOrEmpty(((PlayGamesLocalUser)Social.localUser).GetIdToken()))
        {
            yield return(null);
        }
        string idToken = ((PlayGamesLocalUser)Social.localUser).GetIdToken();

        Credential credential = GoogleAuthProvider.GetCredential(idToken, null);

        auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("canceled");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                return;
            }
            FirebaseUser _user = auth.CurrentUser;
            DatabaseMgr.Instance.CheckUserData(_user.UserId);
        });
    }
Ejemplo n.º 15
0
    // 구글 파이어 베이스 로그인
    public void GoogleLogin(string serverAuthCode)
    {
        //Debug.Log("serverAuth ::: "+serverAuthCode);
        //Debug.Log("null?::: " + firebaseAuth);
        if (firebaseAuth == null)
        {
            // 파이어 베이스 객체가 널이면 ? 초기화를 합니다
            firebaseAuth = Firebase.Auth.FirebaseAuth.DefaultInstance;
        }

        //Debug.Log("null?::: " + firebaseAuth);
        Credential credential = Firebase.Auth.PlayGamesAuthProvider.GetCredential(serverAuthCode);

        //Debug.Log("da");
        // Firebase.Auth.Credential credential =Firebase.Auth.PlayGamesAuthProvider.GetCredential(serverAuthCode);
        //Debug.Log("여기까지 실행 확인 증");
        firebaseAuth.SignInWithCredentialAsync(credential).ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInWithCredentialAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                return;
            }

            Firebase.Auth.FirebaseUser newUser = task.Result;
            Debug.LogFormat("User signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId);
        });
    }
Ejemplo n.º 16
0
    // 이거만 수정하면됨.
    private void SignInWithGoogleOnFirebase(string idToken)
    {
        Credential credential = GoogleAuthProvider.GetCredential(idToken, null);

        auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
        {
            AggregateException ex = task.Exception;
            if (ex != null)
            {
                if (ex.InnerExceptions[0] is FirebaseException inner && (inner.ErrorCode != 0))
                {
                    Debug.Log("\nError code = " + inner.ErrorCode + " Message = " + inner.Message);
                }
                Debug.Log("Sign In Failed.");
                LocalInit();
            }
            else
            {
                Debug.Log("Sign In Successful. >> \r\n" + idToken);
                DBidToken     = idToken;
                localId       = task.Result.UserId;
                isServerLogin = true;
                GetLocalId();
            }
        });
    }
Ejemplo n.º 17
0
    public void LoginUser()
    {
        string emailInput    = email.text;
        string passwordInput = password.text;

        Credential credential =
            EmailAuthProvider.GetCredential(emailInput, passwordInput);

        auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInWithCredentialAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                return;
            }

            Firebase.Auth.FirebaseUser newUser = task.Result;
            Debug.LogFormat("User signed in successfully: {0} ({1})",
                            newUser.DisplayName, newUser.UserId);
        });
    }
Ejemplo n.º 18
0
        private async void MCallBacks_VerificationCompleted(object sender, EventArgs e)
        {
            IsLogin_InProgress(true);
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }
            else
            {
                PhoneAuthCompletedEventArgs verifiedEvent = (PhoneAuthCompletedEventArgs)e;
                if (Dialog != null)
                {
                    Dialog.Dismiss();
                    Dialog.Dispose();
                }
                IAuthResult signinResult = await FirebaseAuth.SignInWithCredentialAsync(verifiedEvent.Credential);

                if (signinResult != null && signinResult.User != null)
                {
                    FirebaseUser user = signinResult.User;
                    Intent       mainactivityIntent = new Intent(this, typeof(MainActivity));
                    StartActivity(mainactivityIntent);
                    IsLogin_InProgress(false);
                    Finish();
                }
                else
                {
                    Toast.MakeText(this, "Authentication failed.", ToastLength.Long).Show();
                    IsLogin_InProgress(false);
                }
            }
        }
Ejemplo n.º 19
0
        public static async Task <bool> FirebaseAuthWithGoogle(FirebaseAuth firebaseAuth, GoogleSignInAccount acct)
        {
            try
            {
                if (Connectivity.NetworkAccess == NetworkAccess.Internet)
                {
                    AuthCredential credential = GoogleAuthProvider.GetCredential(acct.IdToken, null);
                    IAuthResult    result     = await firebaseAuth.SignInWithCredentialAsync(credential);

                    if (result != null && result.User != null)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (FirebaseNetworkException)
            {
                throw;
            }
            return(false);
        }
Ejemplo n.º 20
0
    IEnumerator coFirebaseManager()
    {
        while (System.String.IsNullOrEmpty(((PlayGamesLocalUser)Social.localUser).GetIdToken()))
        {
            yield return(null);
        }

        string idToken     = ((PlayGamesLocalUser)Social.localUser).GetIdToken();
        string accessToken = null;

        Credential credential = GoogleAuthProvider.GetCredential(idToken, accessToken);

        auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInWithCredentialAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                return;
            }

            FirebaseUser newUser = task.Result;
            Debug.LogFormat("User signed in successfully: {0} ({1})",
                            newUser.Email, newUser.UserId);

            Firebase.Auth.FirebaseUser user = auth.CurrentUser;
            userName         = newUser.DisplayName;
            userEmail        = newUser.Email;
            userId           = newUser.UserId;
            loginResult.text = "이름" + userName + "메일" + userEmail + "아이디" + userId + "구글 로그인 굿럭";
        });
    }
Ejemplo n.º 21
0
    // 구글 로그인 구동 부분
    private async void GoogleLoginProcessing(System.Action <bool> callback)
    {
        if (GoogleSignIn.Configuration == null)
        {
            // 설정
            GoogleSignIn.Configuration = new GoogleSignInConfiguration
            {
                RequestIdToken = true,
                RequestEmail   = true,
                // Copy this value from the google-service.json file.
                // oauth_client with type == 3
                WebClientId = "1069253422054-h21hgern8jkr0b4ot3k6echsqpdr7fhk.apps.googleusercontent.com"
            };
        }

        Task <GoogleSignInUser> signIn = GoogleSignIn.DefaultInstance.SignIn();

        TaskCompletionSource <FirebaseUser> signInCompleted = new TaskCompletionSource <FirebaseUser>();

        await signIn.ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.Log("Google Login task.IsCanceled");
                callback(false);
            }
            else if (task.IsFaulted)
            {
                Debug.Log("Google Login task.IsFaulted");
                callback(false);
            }
            else
            {
                Credential credential = Firebase.Auth.GoogleAuthProvider.GetCredential(((Task <GoogleSignInUser>)task).Result.IdToken, null);
                auth.SignInWithCredentialAsync(credential).ContinueWith(authTask =>
                {
                    if (authTask.IsCanceled)
                    {
                        signInCompleted.SetCanceled();
                        Debug.Log("Google Login authTask.IsCanceled");
                        callback(false);
                        return;
                    }
                    if (authTask.IsFaulted)
                    {
                        signInCompleted.SetException(authTask.Exception);
                        Debug.Log("Google Login authTask.IsFaulted");
                        callback(false);
                        return;
                    }

                    user = authTask.Result;
                    Debug.LogFormat("Google User signed in successfully: {0} ({1})", user.DisplayName, user.UserId);
                    callback(true);
                    return;
                });
            }
        });
    }
    private void SignInWithGoogleOnFirebase(string idToken)
    {
        Credential credential = GoogleAuthProvider.GetCredential(idToken, null);

        auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
        {
            AggregateException ex = task.Exception;
        });
    }
Ejemplo n.º 23
0
    public IEnumerator LoginWithFacebook()
    {
        auth.SignOut();
        LoadingScreen.Instance.Show("Siging in with Facebook...");
        yield return(new WaitUntil(() => FB.IsInitialized));

        string        accessToken = "";
        List <string> permissions = new List <string>();

        permissions.Add("public_profile");
        permissions.Add("email");
        FB.LogInWithReadPermissions(permissions, delegate(ILoginResult result)
        {
            if (!string.IsNullOrEmpty(result.Error) || !FB.IsLoggedIn)
            {
                ILogger.Instance.ShowMessage("Failed to login in with facebook", LoggerType.error);
                LoadingScreen.Instance.Hide();
                Debug.LogError(result.Error);
                return;
            }

            accessToken = AccessToken.CurrentAccessToken.TokenString;
            Debug.Log(accessToken);
            FB.API("me?fields=first_name", HttpMethod.GET, delegate(IGraphResult res)
            {
                if (res.Error == null)
                {
                    Debug.Log(res.ResultDictionary["first_name"] + ": " + AccessToken.CurrentAccessToken.UserId + "\nExpires in: " + AccessToken.CurrentAccessToken.ExpirationTime);
                }
            });
            Credential credential = FacebookAuthProvider.GetCredential(accessToken);
            auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
            {
                LoadingScreen.Instance.Hide();
                if (task.IsCanceled)
                {
                    Debug.LogError("SignInWithCredentialAsync was canceled.");
                    return;
                }
                if (task.IsFaulted)
                {
                    Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                    return;
                }
                User = task.Result;
                if (User != null)
                {
                    string name          = User.DisplayName;
                    string email         = User.Email;
                    System.Uri photo_url = User.PhotoUrl;
                    Debug.Log(name + ": " + email + ": " + photo_url);
                    LoginScreenUI.Instance.AfterLogin();
                }
            });
        });
    }
        public async Task <FirebaseUser> FirebaseLoginWithFacebookAsync(string token)
        {
            var credential = FacebookAuthProvider.GetCredential(token);

            _user = (await _firebaseAuth.SignInWithCredentialAsync(credential)).User;

            SaveUser();

            return(User);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Attempts to sign in to Firebase with the given phone number, or provides a verification ID if unable.
        /// </summary>
        /// <param name="phoneNumber">The phone number for the account the user is signing up for or signing into. Make sure to pass in a phone number with country code prefixed with plus sign ('+').</param>
        /// <returns>PhoneNumberSignInResult containing either a verification ID or an IAuthResultWrapper</returns>
        public async Task <PhoneNumberSignInResult> SignInWithPhoneNumberAsync(string phoneNumber)
        {
            var completionHandler = new PhoneNumberVerificationCallbackWrapper();

            PhoneAuthProvider.Instance.VerifyPhoneNumber(phoneNumber, 60, TimeUnit.Seconds, CrossCurrentActivity.Current.Activity, completionHandler);

            PhoneNumberVerificationResult result = null;

            try
            {
                result = await completionHandler.Verify();
            }
            catch (Exception ex)
            {
                throw GetFirebaseAuthException(ex);
            }

            if (result.AuthCredential != null)
            {
                IAuthResult authResult = null;
                try
                {
                    authResult = await _auth.SignInWithCredentialAsync(result.AuthCredential);
                }
                catch (Exception ex)
                {
                    throw GetFirebaseAuthException(ex);
                }

                IFirebaseAuthResult authResultWrapper = new FirebaseAuthResult(authResult);
                return(new PhoneNumberSignInResult()
                {
                    AuthResult = authResultWrapper
                });
            }
            else
            {
                return(new PhoneNumberSignInResult()
                {
                    VerificationId = result.VerificationId
                });
            }
        }
Ejemplo n.º 26
0
    public void LoginWithFaceBook(string tokenId, System.Action <Task <Firebase.Auth.FirebaseUser> > resultCallback)
    {
        if (GlobalVar.DEBUG)
        {
            Debug.Log(String.Format("Attempting to sign in as tokenId {0}...", tokenId));
        }

        Credential facebookid = Firebase.Auth.FacebookAuthProvider.GetCredential(tokenId);

        auth.SignInWithCredentialAsync(facebookid).ContinueWith(resultCallback);
    }
Ejemplo n.º 27
0
    public static void FirebaseLogin()
    {
        Credential cred = GoogleAuthProvider.GetCredential(PlayGamesPlatform.Instance.GetIdToken(),
                                                           PlayGamesPlatform.Instance.GetServerAuthCode());

        auth.SignInWithCredentialAsync(cred).ContinueWith(done => {
            user = done.Result;
            PlayGamesPlatform.Instance.ReportProgress(GPGSIds.achievement_team_player, 100.0, (bool success) => { });
            FormattedUserName = (user.DisplayName.Contains(" ")) ? user.DisplayName.Replace(' ', '_') : user.DisplayName;
        });
    }
Ejemplo n.º 28
0
        void signIn()
        {
            var email    = $"{DisplayName}@blestx.local";
            var password = $"{email}{email.GetHashCode()}";

            Debug.Log($"[EmailAuth::signIn] Signing in {DisplayName} / {email}");

            var credential = EmailAuthProvider.GetCredential(email, password);

            _auth.SignInWithCredentialAsync(credential)
            .ContinueWithOnMainThread(handleSignInWithUser);
        }
Ejemplo n.º 29
0
    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");
        }
    }
Ejemplo n.º 30
0
    /*
     * Signin into Firebase using Facebook Access Token
     */

    private void SignInFirebase(AccessToken accessToken)
    {
        var credential = FacebookAuthProvider.GetCredential(accessToken.TokenString);

        m_auth.SignInWithCredentialAsync(credential).ContinueWithOnMainThread(task =>
        {
            if (task.IsCanceled)
            {
                Debug.Log("Signin cancelled");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.Log("Signin error: " + task.Exception);
                return;
            }

            m_user = task.Result;
            Debug.Log($"User signed in: {m_user.DisplayName}, {m_user.UserId}.");
            LoadHome(1);
        });
    }