示例#1
0
    internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
    {
        if (task.IsFaulted)
        {
            using (IEnumerator <System.Exception> enumerator =
                       task.Exception.InnerExceptions.GetEnumerator()) {
                if (enumerator.MoveNext())
                {
                    GoogleSignIn.SignInException error =
                        (GoogleSignIn.SignInException)enumerator.Current;
                    Debug.Log("Got Error: " + error.Status + " " + error.Message);
                }
                else
                {
                    Debug.Log("Got Unexpected Exception?!?" + task.Exception);
                }
            }
        }
        else if (task.IsCanceled)
        {
            Debug.Log("Canceled");
        }
        else // Google auth success
        {
            userInfo = new UserInfo
            {
                gid         = task.Result.UserId,
                displayName = task.Result.DisplayName,
                idToken     = task.Result.IdToken
            };

            // Send user info to check if existing mathgo user
            StartCoroutine(CheckUserExists());
        }
    }
示例#2
0
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     if (task.IsFaulted)
     {
         using (IEnumerator <Exception> enumerator = task.Exception.InnerExceptions.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
                 AddToInformation("Got Error: " + error.Status + " " + error.Message);
             }
             else
             {
                 AddToInformation("Got Unexpected Exception?!?" + task.Exception);
             }
         }
     }
     else if (task.IsCanceled)
     {
         AddToInformation("Canceled");
     }
     else
     {
         AddToInformation("Welcome: " + task.Result.DisplayName + "!");
         AddToInformation("Email = " + task.Result.Email);
         AddToInformation("Google ID Token = " + task.Result.IdToken);
         AddToInformation("Email = " + task.Result.Email);
         SignInWithGoogleOnFirebase(task.Result.IdToken);
     }
 }
示例#3
0
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     if (task.IsFaulted)
     {
         using (IEnumerator <System.Exception> enumerator =
                    task.Exception.InnerExceptions.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error =
                     (GoogleSignIn.SignInException)enumerator.Current;
                 AddStatusText("구글 로그인 에러: " + error.Status + " " + error.Message);
             }
             else
             {
                 AddStatusText("구글 로그인 예외" + task.Exception);
             }
         }
     }
     else if (task.IsCanceled)
     {
         AddStatusText("구글 로그인 취소");
     }
     else
     {
         server.userID = task.Result.DisplayName;
         server.SendGoogleToken(task.Result.AuthCode);
         //accountType = AccountType.Google;
         AddStatusText("구글 성공: ");
         SetButton();
         //ToastManager.Instance.ShowToastOnUiThread("구글 로그인 성공");
     }
 }
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     if (task.IsFaulted)
     {
         using (IEnumerator <System.Exception> enumerator = task.Exception.InnerExceptions.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
                 //AddStatusText("Got Error: " + error.Status + " " + error.Message);
                 UiManager.Instance.ChangeScreen(0);
             }
             //else
             //{
             //  AddStatusText("Got Unexpected Exception?!?" + task.Exception);
             //}
             UiManager.Instance.ChangeScreen(0);
         }
     }
     else if (task.IsCanceled)
     {
         //AddStatusText("Canceled");
         UiManager.Instance.ChangeScreen(0);
     }
     else
     {
         //AddStatusText("Welcome: " + task.Result.DisplayName + "!");
         m_PlayerName.text = task.Result.DisplayName;
         GameManager.Instance.StartGameplay();
     }
 }
示例#5
0
    public void OnAuthenticationFinished(Task <GoogleSignInUser> task)
    {
        if (task.IsFaulted)
        {
            using (IEnumerator <Exception> enumerator = task.Exception.InnerExceptions.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
                    AddToInformation("Got Error: " + error.Status + " " + error.Message);
                }
                else
                {
                    AddToInformation("Got Unexpected Exception?!?" + task.Exception);
                }
            }
        }
        else if (task.IsCanceled)
        {
            AddToInformation("Canceled");
        }
        else if (task.IsCompleted)
        {
            var result = task.Result;

            Usermsg.text = "Welcome " + result.GivenName + "!" + "\nLets Play!!!";
            AddToInformation("Welcome: " + result.GivenName + "!");
            AddToInformation("Email = " + result.Email);
            AddToInformation("Image Url = " + result.ImageUrl);
            Image_url = result.ImageUrl.ToString();
            Debug.Log("Got the info from task");
            DoneDataSaving(result.ImageUrl.ToString());
            SignInWithGoogleOnFirebase(result.IdToken);
        }
    }
    private void OnAuthenticationFinished(Task <GoogleSignInUser> task)
    {
        if (task.IsFaulted)
        {
            // Check for exceptions
            using (IEnumerator <System.Exception> enumerator = task.Exception.InnerExceptions.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
                    Debug.LogError($"Error: {error.Status} {error.Message}");
                }
                else
                {
                    Debug.Log($"Unexpected Exception {task.Exception}");
                }
            }
        }
        else if (task.IsCanceled)
        {
            Debug.Log("Canceled");
        }
        else
        {
            Debug.Log($"Welcome {task.Result.DisplayName}");
            Debug.Log($"Email: {task.Result.Email}");
            Debug.Log($"Google ID Token {task.Result.IdToken}");

            GoogleSignInFirebase(task.Result.IdToken);
        }
    }
示例#7
0
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     if (task.IsFaulted)
     {
         using (IEnumerator <System.Exception> enumerator =
                    task.Exception.InnerExceptions.GetEnumerator()) {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error =
                     (GoogleSignIn.SignInException)enumerator.Current;
                 AddStatusText("Got Error: " + error.Status + " " + error.Message);
             }
             else
             {
                 AddStatusText("Got Unexpected Exception?!?" + task.Exception);
             }
         }
     }
     else if (task.IsCanceled)
     {
         AddStatusText("Canceled");
     }
     else
     {
         AddStatusText("Welcome: " + task.Result.DisplayName + "!");
         writeNewUser(task.Result.UserId, task.Result.DisplayName, task.Result.Email, DateTime.Now.ToString());
         PlayerPrefs.SetInt("signed", 1);
         start.SetActive(true);
         signButton.SetActive(false);
     }
 }
    private void SignInFinished(Task <GoogleSignInUser> signInTask)
    {
        if (signInTask.IsFaulted)
        {
            using (IEnumerator <System.Exception> enumerator = signInTask.Exception.InnerExceptions.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
                    status += "Error: " + error.Status + " " + error.Message + "\n";
                }
                else
                {
                    status += "Got unexpected error " + signInTask.Exception + "\n";
                }
            }
        }
        else if (signInTask.IsCanceled)
        {
            status += "Sign in request was canceled\n";
        }
        else
        {
            status += "Success! Welcome " + signInTask.Result.DisplayName + ".\n";
            status += "Id token: " + signInTask.Result.IdToken;

            SignInFirebase(signInTask.Result.IdToken, null);
        }
    }
 //use a callback with a task to easily get results from the callback in order to get the values you need.
 public void OnGoogleAuthSignIn(Task <GoogleSignInUser> task)
 {
     if (task.IsFaulted)
     {
         using (IEnumerator <System.Exception> enumerator =
                    task.Exception.InnerExceptions.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error =
                     (GoogleSignIn.SignInException)enumerator.Current;
                 statusText = "Got Error: " + error.Status + " " + error.Message;
             }
             else
             {
                 statusText = "Got Unexpected Exception?!?" + task.Exception;
             }
         }
     }
     else if (task.IsCanceled)
     {
         statusText = "Canceled";
     }
     else
     {
         authCode   = task.Result.AuthCode;
         idToken    = task.Result.IdToken;
         email      = task.Result.Email;
         statusText = "Welcome: " + task.Result.DisplayName + "!\n" + idToken + " = idToken\n" + email + " = email\n" + authCode + " = authCode";
     }
 }
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     if (task.IsFaulted)
     {
         using (IEnumerator <System.Exception> enumerator =
                    task.Exception.InnerExceptions.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error =
                     (GoogleSignIn.SignInException)enumerator.Current;
                 AddStatusText("Got Error: " + error.Status + " " + error.Message);
             }
             else
             {
                 AddStatusText("Got Unexpected Exception?!?" + task.Exception);
             }
         }
     }
     else if (task.IsCanceled)
     {
         AddStatusText("Canceled");
     }
     else
     {
         AddStatusText("Welcome: " + task.Result.DisplayName + "!");
     }
 }
示例#11
0
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     try
     {
         if (task.IsFaulted)
         {
             using (IEnumerator <System.Exception> enumerator = task.Exception.InnerExceptions.GetEnumerator())
             {
                 if (enumerator.MoveNext())
                 {
                     GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
                     Debug.LogWarning("Got Error: " + error.Status + " " + error.Message);
                 }
                 else
                 {
                     Debug.LogWarning("Got Unexpected Exception?!?" + task.Exception);
                 }
             }
         }
         else if (task.IsCanceled)
         {
             Debug.LogWarning("Canceled");
         }
         else
         {
             SignInWithGoogleOnFirebase(task.Result.IdToken);
         }
     }
     catch (Exception e)
     {
         Debug.LogWarning(e.Message);
     }
 }
示例#12
0
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     if (task.IsFaulted)
     {
         using (IEnumerator <System.Exception> enumerator =
                    task.Exception.InnerExceptions.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
                 status = "Got Error: " + error.Status + " " + error.Message;
             }
             else
             {
                 status = "Got Unexpected Exception:" + task.Exception;
             }
         }
     }
     else if (task.IsCanceled)
     {
         status = "Canceled";
     }
     else
     {
         GoogleSignInHelper.User = task.Result;
         BackendService.Instance.GetAccessToken();
     }
 }
示例#13
0
	void OnGoogleAuthenticationFinished(Task<GoogleSignInUser> task)
	{
		if (task.IsFaulted)
		{
			using (IEnumerator<System.Exception> enumerator =
					task.Exception.InnerExceptions.GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
				}
			}
		}
		else if (task.IsCanceled)
		{
		}
		else
		{
			//Collect the user's credentials and register them with the firebase server.
      
			Credential credential = GoogleAuthProvider.GetCredential(task.Result.IdToken, null);
			mAuth.SignInWithCredentialAsync(credential).ContinueWithOnMainThread(authTask =>
			{
				FirebaseUser = firebaseAuth.CurrentUser;
        Debug.Log(firebaseUser.Email);
				PlayerPrefs.SetInt("itIsRegistered", 1);
			});
		}		
	}
// G+ auth internal tasks
    internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
    {
        if (task.IsFaulted)
        {
            using (IEnumerator <System.Exception> enumerator =
                       task.Exception.InnerExceptions.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    GoogleSignIn.SignInException error =
                        (GoogleSignIn.SignInException)enumerator.Current;
                    Debug.Log("Got Error: " + error.Status + " " + error.Message);
                }
                else
                {
                    Debug.Log("Got Unexpected Exception?!?" + task.Exception);
                }
            }
        }
        else if (task.IsCanceled)
        {
            Debug.Log("Canceled");
        }
        else
        {
            //succes take the google id Token and pass it to firebase authentication with credintails function
            Debug.Log("Welcome: " + task.Result.UserId + "!");
            SignInWithGoogleOnFirebase(task.Result.IdToken);
            //ContinueWithUserDetails(task.Result.DisplayName, task.Result.ImageUrl.ToString(), task.Result.Email);
        }
    }
示例#15
0
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     if (task.IsFaulted)
     {
         using (IEnumerator <Exception> enumerator = task.Exception.InnerExceptions.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
                 UpdateStatusSignIn("Got Error: " + error.Status + " " + error.Message);
             }
             else
             {
                 UpdateStatusSignIn("Got Unexpected Exception?!?" + task.Exception);
             }
         }
     }
     else if (task.IsCanceled)
     {
         UpdateStatusSignIn("Canceled");
     }
     else
     {
         // UpdateStatusSignIn("Update to FirebaseAuth with Google");
         SignInWithGoogleOnFirebase(task.Result.IdToken);
     }
 }
示例#16
0
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     if (task.IsFaulted)
     {
         using (IEnumerator <System.Exception> enumerator =
                    task.Exception.InnerExceptions.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error =
                     (GoogleSignIn.SignInException)enumerator.Current;
                 LogMsg("Authentication got Error: " + error.Status + " " + error.Message);
             }
             else
             {
                 LogMsg(task.Exception.ToString());
             }
         }
     }
     else if (task.IsCanceled)
     {
         LogMsg("Authentication canceled");
     }
     else
     {
         LogMsg("Welcome: " + task.Result.DisplayName + "!");
         Authorize(task.Result.IdToken);
     }
 }
示例#17
0
    /*
     * Signin into Firebase using Google Credential
     */

    void OnAuthenticationFinished(Task <GoogleSignInUser> task)
    {
        Debug.Log("OnAuthenticationFinished1 " + task.Status);
        if (task.IsFaulted)
        {
            using (IEnumerator <System.Exception> enumerator =
                       task.Exception.InnerExceptions.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    GoogleSignIn.SignInException error =
                        (GoogleSignIn.SignInException)enumerator.Current;

                    Debug.Log("Got Error: " + error.Status + " " + error.Message);
                }
                else
                {
                    Debug.Log("Got Unexpected Exception?!?" + task.Exception);
                }
            }
        }
        else if (task.IsCanceled)
        {
            Debug.Log("Canceled");
        }
        else
        {
            Debug.Log("Welcome: " + task.Result.DisplayName + "!");
            Debug.Log("Toekn: " + task.Result.IdToken);
            Debug.Log("AuthCode: " + task.Result.AuthCode);
            Debug.Log("UserId: " + task.Result.UserId);


            Credential credential = GoogleAuthProvider.GetCredential(task.Result.IdToken, null);
            m_auth.SignInWithCredentialAsync(credential).ContinueWithOnMainThread(t => {
                if (t.IsCanceled)
                {
                    if (Debug.isDebugBuild)
                    {
                        Debug.LogError("SignInWithCredentialAsync was canceled.");
                    }
                    return;
                }
                if (t.IsFaulted)
                {
                    if (Debug.isDebugBuild)
                    {
                        Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                    }
                    return;
                }

                m_user = t.Result;
                Debug.LogFormat("User signed in successfully: {0} ({1})", m_user.DisplayName, m_user.UserId);
                LoadHome(1);
            });
        }
    }
    //Handle when Google Sign In successfully
    void OnGoogleAuthenticationFinished(Task <GoogleSignInUser> task)
    {
        if (task.IsFaulted)
        {
            using (IEnumerator <System.Exception> enumerator =
                       task.Exception.InnerExceptions.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    GoogleSignIn.SignInException error =
                        (GoogleSignIn.SignInException)enumerator.Current;
                    UnityEngine.Debug.Log("Got Error: " + error);
                    ErrorPanel.SetActive(true);
                    // ErrorMessage.text = (string)error;
                }
                else
                {
                    UnityEngine.Debug.Log("Got Unexpected Exception?!?");
                }
            }
        }
        else if (task.IsCanceled)
        {
            UnityEngine.Debug.Log("Canceled");
        }
        else
        {
            UnityEngine.Debug.Log("Google Sign-In successed");

            UnityEngine.Debug.Log("IdToken: " + task.Result.IdToken);
            UnityEngine.Debug.Log("ImageUrl: " + task.Result.ImageUrl.AbsoluteUrlOrEmptyString());
            UnityEngine.Debug.Log("Email: " + task.Result.Email);

            //Start Firebase Auth
            Firebase.Auth.Credential credential = Firebase.Auth.GoogleAuthProvider.GetCredential(task.Result.IdToken, null);
            auth.SignInWithCredentialAsync(credential).ContinueWith(t =>
            {
                if (t.IsCanceled)
                {
                    UnityEngine.Debug.Log("SignInWithCredentialAsync was canceled.");
                    return;
                }
                if (t.IsFaulted)
                {
                    UnityEngine.Debug.Log("SignInWithCredentialAsync encountered an error: " + t.Exception);
                    return;
                }

                user = auth.CurrentUser;
                UnityEngine.Debug.Log("Email: " + user.Email);

                // SceneManager.LoadScene("Game", LoadSceneMode.Single);
                onLogedIn.SetActive(true);
            });
        }
    }
    /// <summary>
    /// called in googlesignin() after to check authentication success
    /// </summary>
    /// <param name="task"> Contains all the output returned by google</param>
    internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
    {
        if (task.IsFaulted)
        {
            using (IEnumerator <System.Exception> enumerator =
                       task.Exception.InnerExceptions.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    GoogleSignIn.SignInException error =
                        (GoogleSignIn.SignInException)enumerator.Current;
                    Debug.Log("Got Error: " + error.Status + " " + error.Message);
                }
                else
                {
                    Debug.Log("Got Unexpected Exception?!?" + task.Exception);
                }
            }
        }
        else if (task.IsCanceled)
        {
            Debug.Log("Canceled");
        }

        else
        {
            //signin
            debtext.text = "Welcome: " + task.Result.DisplayName + "!";
            Debug.Log("Hello!" + task.Result.DisplayName);
            username = task.Result.DisplayName;
            signedIn = true;
            SaveUserData();
        }

        Firebase.Auth.Credential credential =
            Firebase.Auth.GoogleAuthProvider.GetCredential(task.Result.IdToken, null);
        auth.SignInWithCredentialAsync(credential).ContinueWith(fbtask =>
        {
            if (fbtask.IsCanceled)
            {
                Debug.LogError("SignInWithCredentialAsync was canceled.");
                return;
            }
            if (fbtask.IsFaulted)
            {
                Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                return;
            }

            Firebase.Auth.FirebaseUser newUser = fbtask.Result;
            fbdebtext.text = ("User signed in successfully:" + newUser.DisplayName + newUser.UserId);
            Debug.Log("Logged firebase:" + newUser.DisplayName + newUser.UserId);
        });
    }
示例#20
0
    private void OnAuthenticationFinished(Task <GoogleSignInUser> task)
    {
        TaskCompletionSource <FirebaseUser> signInCompleted = new TaskCompletionSource <FirebaseUser> ();

        if (task.IsFaulted)
        {
            using (IEnumerator <System.Exception> enumerator =
                       task.Exception.InnerExceptions.GetEnumerator()) {
                if (enumerator.MoveNext())
                {
                    GoogleSignIn.SignInException error =
                        (GoogleSignIn.SignInException)enumerator.Current;
                    AddStatusText("Got Error: " + error.Status + " " + error.Message);
                }
                else
                {
                    AddStatusText("Got Unexpected Exception?!?" + task.Exception);
                }
            }
        }
        else if (task.IsCanceled)
        {
            AddStatusText("Canceled");
        }
        else
        {
            AddStatusText("Welcome: " + task.Result.DisplayName + "!");
            //  AddStatusText("Email = " + task.Result.Email);

            string token = task.Result.IdToken;
            AddStatusText("Google ID Token = " + token);
            // SignInWithGoogleOnFirebase(token);
            //SceneManager.LoadSceneAsync("scene_01");

            Credential credential = Firebase.Auth.GoogleAuthProvider.GetCredential(((Task <GoogleSignInUser>)task).Result.IdToken, null);
            auth.SignInWithCredentialAsync(credential).ContinueWith(authTask => {
                if (authTask.IsCanceled)
                {
                    AddToInformation("Login is Canceled!:");
                    signInCompleted.SetCanceled();
                }
                else if (authTask.IsFaulted)
                {
                    AddToInformation("Expception!");
                    signInCompleted.SetException(authTask.Exception);
                }
                else
                {
                    signInCompleted.SetResult(((Task <FirebaseUser>)authTask).Result);
                    SceneManager.LoadSceneAsync("scene_01");
                }
            });
        }
    }
    void SignInUser()
    {
        Debug.Log("Signing In");

#if UNITY_ANDROID && !UNITY_EDITOR
        GoogleSignIn.Configuration = configuration;
        GoogleSignIn.Configuration.UseGameSignIn   = false;
        GoogleSignIn.Configuration.RequestIdToken  = true;
        GoogleSignIn.Configuration.RequestAuthCode = true;

        GoogleSignIn.DefaultInstance.SignIn().ContinueWith(task =>
        {
            if (task.IsFaulted)
            {
                using (IEnumerator <System.Exception> enumerator =
                           task.Exception.InnerExceptions.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        GoogleSignIn.SignInException error =
                            (GoogleSignIn.SignInException)enumerator.Current;
                        Debug.Log("Got Error: " + error.Status + " " + error.Message);
                    }
                    else
                    {
                        Debug.Log("Got Unexpected Exception?!?" + task.Exception);
                    }
                }
            }
            else if (task.IsCanceled)
            {
                Debug.Log("Canceled");
            }
            else
            {
                Debug.Log("Welcome: " + task.Result.DisplayName + "!");


                PlayFabAuthService.Instance.AuthCode = task.Result.AuthCode;
                PlayFabAuthService.Instance.Authenticate(Authtypes.GoogleAccount);
            }
        });
#else
        PlayFabAuthService.Instance.Authenticate(Authtypes.Silent);
#endif
    }
示例#22
0
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     loadDashboard = false;
     if (task.IsFaulted)
     {
         using (IEnumerator <Exception> enumerator = task.Exception.InnerExceptions.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error = (GoogleSignIn.SignInException)enumerator.Current;
                 AddToInformation("Got Error: " + error.Status + " " + error.Message);
                 ViewMessageOnScreen("Got Error: " + error.Status + " " + error.Message);
             }
             else
             {
                 AddToInformation("Got Unexpected Exception " + task.Exception);
                 ViewMessageOnScreen("Got Unexpected Exception " + task.Exception);
             }
         }
     }
     else if (task.IsCanceled)
     {
         AddToInformation("Canceled ... ");
         ViewMessageOnScreen("Canceled ... ");
     }
     else
     {
         AddToInformation("Welcome: " + task.Result.DisplayName + "!");
         AddToInformation("Email: " + task.Result.Email);
         loadDashboard              = true;
         Globals.username           = task.Result.DisplayName;
         Globals.email              = task.Result.Email;
         Globals.userId             = task.Result.UserId;
         Globals.isLoggedIn         = true;
         Globals.loggedInWithGoogle = true;
         //AddToInformation("Google Id Token: " + task.Result.IdToken);
         //AddToInformation("Google Id Token: " + task.Result.IdToken);
         SignInWithGoogleOnFirebase(task.Result.IdToken);
     }
 }
    void OnGoogleAuthenticationFinished(Task <GoogleSignInUser> task)
    {
        if (task.IsFaulted)
        {
            using (IEnumerator <System.Exception> enumerator =
                       task.Exception.InnerExceptions.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    GoogleSignIn.SignInException error =
                        (GoogleSignIn.SignInException)enumerator.Current;
                    WriteLog("Got Error: " + error.Status + " " + error.Message, "ERR");
                }
                else
                {
                    WriteLog("Got Unexpected Exception?!?" + task.Exception, "ERR");
                }
            }
        }
        else if (task.IsCanceled)
        {
            WriteLog("Canceled");
        }
        else
        {
            WriteLog("Google Sign-In successed");

            WriteLog("IdToken: " + task.Result.IdToken);
            WriteLog("ImageUrl: " + task.Result.ImageUrl.AbsolutePath);

            //Set imageUrl
            //imageUrl = task.Result.ImageUrl.AbsoluteUrlOrEmptyString();

            //Start Firebase Auth

            MessagingSystem.Instance.DispatchEvent(new LoginEvents.GoogleSignInAuthEvent(task.Result.IdToken));
        }
    }
示例#24
0
        internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
        {
            if (task.IsFaulted)
            {
                using (IEnumerator <System.Exception> enumerator =
                           task.Exception.InnerExceptions.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        GoogleSignIn.SignInException error =
                            (GoogleSignIn.SignInException)enumerator.Current;
                        AddStatusText("Got Error: " + error.Status + " " + error.Message + " " + error.Data);
                    }
                    else
                    {
                        AddStatusText("Got Unexpected Exception?!?" + task.Exception);
                    }
                }
            }
            else if (task.IsCanceled)
            {
                AddStatusText("Canceled");
            }
            else
            {
                messages.Clear();
                email = task.Result.Email;

                string user_email = task.Result.Email;
                // string user_birthday = user_data["birthday"].ToString();
                string user_name     = task.Result.DisplayName;
                string user_birthday = "";//user_data["birthday"].ToString();
                string user_id       = task.Result.UserId;
                StartCoroutine(register(user_email, user_name, user_birthday, user_id));
                AddStatusText(email);
            }
        }
示例#25
0
 internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
 {
     if (task.IsFaulted)
     {
         using (IEnumerator <System.Exception> enumerator =
                    task.Exception.InnerExceptions.GetEnumerator())
         {
             if (enumerator.MoveNext())
             {
                 GoogleSignIn.SignInException error =
                     (GoogleSignIn.SignInException)enumerator.Current;
                 AddStatusText("Got Error: " + error.Status + " " + error.Message);
             }
             else
             {
                 AddStatusText("Got Unexpected Exception?!?" + task.Exception);
             }
         }
         OnLoginFinish(true);
     }
     else if (task.IsCanceled)
     {
         AddStatusText("Canceled");
         OnLoginFinish(true);
     }
     else
     {
         AddStatusText("Welcome: " + task.Result.DisplayName + "!");
         AddStatusText(task.Result.ImageUrl.OriginalString);
         StartCoroutine(ServiceClient.DoLogin3rd(task.Result.DisplayName,
                                                 task.Result.UserId,
                                                 "Google",
                                                 task.Result.IdToken,
                                                 task.Result.ImageUrl.OriginalString,
                                                 OnLoginFinish));
     }
 }
示例#26
0
        internal void OnAuthenticationFinished(Task <GoogleSignInUser> task)
        {
            if (task.IsFaulted)
            {
                ShowButtons();
                using (IEnumerator <System.Exception> enumerator =
                           task.Exception.InnerExceptions.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        ShowButtons();
                        GoogleSignIn.SignInException error =
                            (GoogleSignIn.SignInException)enumerator.Current;
                        AddStatusText("Got Error: " + error.Status + " " + error.Message);
                        OnSignOut();
                        GameSettings.MyDebug(statusText.text);
                    }
                    else
                    {
                        ShowButtons();
                        AddStatusText("Got Unexpected Exception?!?" + task.Exception);
                        OnSignOut();
                        GameSettings.MyDebug(statusText.text);
                    }
                }
            }
            else if (task.IsCanceled)
            {
                ShowButtons();
                OnSignOut();
                AddStatusText("Canceled");
                GameSettings.MyDebug(statusText.text);
            }
            else
            {
                AddStatusText("Welcome: " + task.Result.DisplayName + "!" + task.Result);
                GameSettings.MyDebug(statusText.text);

                Firebase.Auth.Credential credential =
                    Firebase.Auth.GoogleAuthProvider.GetCredential(task.Result.IdToken, null);
                auth.SignInWithCredentialAsync(credential).ContinueWith(task2 => {
                    if (task2.IsCanceled)
                    {
                        ShowButtons();
                        GameSettings.MyDebug("SignInWithCredentialAsync was canceled.");
                        OnSignOut();
                        return;
                    }
                    if (task2.IsFaulted)
                    {
                        ShowButtons();
                        GameSettings.MyDebug("SignInWithCredentialAsync encountered an error: " + task2.Exception);
                        OnSignOut();
                        return;
                    }

                    user = task2.Result;
                    GameSettings.user = user;
                    GameSettings.MyDebug("User signed in successfully: {0} ({1}) " + user.UserId + " - " + user.UserId);

                    CallServer();
                });
            }
        }