// Use this for initialization void Start() { auth = Firebase.Auth.FirebaseAuth.DefaultInstance; user = auth.CurrentUser; if (user != null) { // テキストの表示 this.userName.text = user.DisplayName; Debug.Log(user.DisplayName); } FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://hamukatsu2-9bebb.firebaseio.com/"); // Get the root reference location of the database. reference = FirebaseDatabase.DefaultInstance.RootReference; Debug.Log(user.UserId); Debug.Log(user.DisplayName); User newUser = new User(user.DisplayName); string json = JsonUtility.ToJson(newUser); reference.Child("users").Child(user.UserId).SetRawJsonValueAsync(json); FirebaseDatabase.DefaultInstance.GetReference("users").ValueChanged += HandleValueChanged; }
public void GetOTP() //Function to send otp to the valid user mobile number { Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; //Firebase auth instance creation to start authorization activity uint phoneAuthTimeoutMs = 10000; // PhoneAuthProvider provider = PhoneAuthProvider.GetInstance(auth); provider.VerifyPhoneNumber("+91" + mobile.text, phoneAuthTimeoutMs, null, verificationCompleted: (credential) => { Debug.Log("1"); //OnVerifyOTP(credential); }, verificationFailed: (error) => { Debug.Log("Verification failed"); }, codeSent: (id, token) => { phoneVerificationId = id; Debug.Log("+91" + mobile.text); Debug.Log("SMS Has been sent and the verification Id is " + id); }, codeAutoRetrievalTimeOut: (id) => { Debug.Log("Code Retrieval Time out"); }); }
private void OnLogIn(ILoginResult result) { if (FB.IsLoggedIn) { Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; AccessToken token = AccessToken.CurrentAccessToken; Firebase.Auth.Credential credential = Firebase.Auth.FacebookAuthProvider.GetCredential(token + ""); 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); userIdText.text = newUser.UserId; }); Debug.LogError("User sign tmam"); } }
private Task <PhoneNumberVerificationResult> VerifyPhoneNumberAsync(Firebase.Auth.FirebaseAuth auth, IPhoneMultiFactorInfo phoneMultiFactorInfo, IMultiFactorSession multiFactorSession, TimeSpan timeout, bool?requiresSmsValidation = null) { var activity = CrossCurrentActivity.Current.Activity ?? throw new NullReferenceException("current activity is null"); var tcs = new TaskCompletionSource <PhoneNumberVerificationResult>(); var callbacks = new Callbacks(tcs); var builder = PhoneAuthOptions.NewBuilder(auth) .SetActivity(activity) .SetCallbacks(callbacks) .SetMultiFactorHint(phoneMultiFactorInfo.ToNative()) .SetMultiFactorSession(multiFactorSession.ToNative()) .SetTimeout(new Java.Lang.Long((long)timeout.TotalMilliseconds), TimeUnit.Milliseconds); if (requiresSmsValidation.HasValue) { builder.RequireSmsValidation(requiresSmsValidation.Value); } auth.FirebaseAuthSettings.SetAutoRetrievedSmsCodeForPhoneNumber(null, null); PhoneAuthProvider.VerifyPhoneNumber(builder.Build()); return(tcs.Task); }
private void InitializeFirebase() { Debug.Log("Setting up Firebase Auth"); Auth = Firebase.Auth.FirebaseAuth.DefaultInstance; FirebaseApp.DefaultInstance.SetEditorDatabaseUrl(databaseURL); Reference = FirebaseDatabase.DefaultInstance.RootReference; }
public void Login() { email = emailField.GetComponent <Text>().text; password = passwordField.GetComponent <Text>().text; authReference = Firebase.Auth.FirebaseAuth.DefaultInstance; if (!string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(email)) { authReference.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => { if (task.IsCanceled) { print("Login User was cancelled"); return; } if (task.IsFaulted) { print("Login User encountered error"); return; } print("LOGIN SUCCESSFUL"); SceneManager.LoadScene("HomeScene"); }); } else { print("Input is Empty"); } }
void InitializeFirebase() { auth = Firebase.Auth.FirebaseAuth.DefaultInstance; user = auth.CurrentUser; //auth.StateChanged += AuthStateChanged; //AuthStateChanged(this, null); }
// Start is called before the first frame update void Start() { authManager.InitializeFirebase(); dbManager.Awake(); auth = Firebase.Auth.FirebaseAuth.DefaultInstance; signinFacebookButton.onClick.AddListener(OnSignInFacebook); }
public void CreateUser(string[] context, Action <Firebase.Auth.FirebaseUser> onCompleted, Action onFaulted, Action onCanceled) { if (context == null || context.Length != 2) { DebugUtil.D.LogError("EmailAuth CreateUser context error."); onFaulted.SafeCall(); return; } Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; auth.CreateUserWithEmailAndPasswordAsync(context[0], context[1]).ContinueWith( task => { if (task.IsCanceled) { DebugUtil.D.LogError("EmailAuth CreateUser was canceled."); onCanceled.SafeCall(); return; } if (task.IsFaulted) { DebugUtil.D.LogError("EmailAuth CreateUser encountered an error: " + task.Exception); onFaulted.SafeCall(); return; } if (task.IsCompleted) { Firebase.Auth.FirebaseUser newUser = task.Result; onCompleted.SafeCall(newUser); } } ); }
void InitializeFirebase() { FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://grapphia.firebaseio.com/"); reference = FirebaseDatabase.DefaultInstance.RootReference; auth = Firebase.Auth.FirebaseAuth.DefaultInstance; user_fb = auth.CurrentUser; }
/// <summary> /// Register for events at the CloudRecoBehaviour /// </summary> void Start() { authReference = Firebase.Auth.FirebaseAuth.DefaultInstance; authUser = authReference.CurrentUser; if (authUser == null) { SceneManager.LoadScene("LoginScene"); } storage = Firebase.Storage.FirebaseStorage.DefaultInstance; FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://card-677f1.firebaseio.com/"); // Register this event handler at the CloudRecoBehaviour m_CloudRecoBehaviour = GetComponent <CloudRecoBehaviour>(); if (m_CloudRecoBehaviour) { m_CloudRecoBehaviour.RegisterEventHandler(this); } /* * if (m_CloudActivityIcon) * { * m_CloudActivityIcon.enabled = false; * } */ }
public void FBFirebaseAuth(AccessToken accessToken) { Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; Debug.Log(FB.IsInitialized); Debug.Log("Facebook is clicked"); Firebase.Auth.Credential credential = Firebase.Auth.FacebookAuthProvider.GetCredential(accessToken.TokenString); auth.SignInWithCredentialAsync(credential).ContinueWith(task => { Debug.Log(credential.ToString()); Debug.Log(task.ToString()); 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); Debug.Log(newUser.Email); }); }
public void Push() { string newEmail = ""; string newPassword = ""; FirebaseAuth.DefaultInstance.SignInWithEmailAndPasswordAsync(newEmail + "@unreal.com", newPassword).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("SignInWithEmailAndPasswordAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception); return; } newUser = task.Result; //changetextsuccess = true; Debug.LogFormat("User signed in successfully: {0} ({1})", newUser.DisplayName, newUser.UserId); ///start updating auth = Firebase.Auth.FirebaseAuth.DefaultInstance; }); }
public void SignIn(string[] context, Action <Firebase.Auth.FirebaseUser> onCompleted, Action onFaulted, Action onCanceled) { Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; auth.SignInAnonymouslyAsync().ContinueWith( task => { if (task.IsCanceled) { DebugUtil.D.LogError("SignInAnonymouslyAsync was canceled."); onCanceled.SafeCall(); return; } if (task.IsFaulted) { DebugUtil.D.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception); onFaulted.SafeCall(); return; } if (task.IsCompleted) { Firebase.Auth.FirebaseUser newUser = task.Result; onCompleted.SafeCall(newUser); } } ); }
private void FacebookAuth(string accessToken) { Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; Firebase.Auth.Credential credential = Firebase.Auth.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); }); Firebase.Auth.FirebaseUser user = auth.CurrentUser; if (user != null) { string myname = user.DisplayName; string myemail = user.Email; System.Uri myphoto_url = user.PhotoUrl; // 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. string uid = user.UserId; } }
public AuthWrapper(Firebase.Auth.FirebaseAuth auth) { _auth = auth ?? throw new ArgumentNullException(nameof(auth)); _auth.AuthState += OnAuthStateChanged; _auth.IdToken += OnIdTokenChanged; }
public void NewSignIn() { auth = FirebaseAuth.DefaultInstance; string phoneNumber = "+79244225416"; uint phoneAuthTimeoutMs = 100000; PhoneAuthProvider provider = PhoneAuthProvider.GetInstance(auth); provider.VerifyPhoneNumber(phoneNumber, phoneAuthTimeoutMs, null, verificationCompleted: (credential) => { Debug.Log("Completed"); }, verificationFailed: (error) => { Debug.Log("error"); }, codeSent: (id, token) => { Debug.Log(id); }, codeAutoRetrievalTimeOut: (id) => { Debug.Log("Phone Auth, auto-verification timed out"); }); }
void initializeFirebase() { FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://strokesurvivors-605a1.firebaseio.com/"); auth = Firebase.Auth.FirebaseAuth.DefaultInstance; auth.StateChanged += AuthStateChanged; AuthStateChanged(this, null); }
void InitializeFirebase() { Debug.Log("Setting up Firebase Auth"); auth = Firebase.Auth.FirebaseAuth.DefaultInstance; auth.StateChanged += AuthStateChanged; AuthStateChanged(this, null); }
protected void InitializeFirebase() { DebugLog("Setting up Firebase Auth"); auth = Firebase.Auth.FirebaseAuth.DefaultInstance; auth.StateChanged += AuthStateChanged; auth.IdTokenChanged += IdTokenChanged; // Specify valid options to construct a secondary authentication object. if (otherAuthOptions != null && !(String.IsNullOrEmpty(otherAuthOptions.ApiKey) || String.IsNullOrEmpty(otherAuthOptions.AppId) || String.IsNullOrEmpty(otherAuthOptions.ProjectId))) { try { otherAuth = Firebase.Auth.FirebaseAuth.GetAuth(Firebase.FirebaseApp.Create( otherAuthOptions, "Secondary")); otherAuth.StateChanged += AuthStateChanged; otherAuth.IdTokenChanged += IdTokenChanged; } catch (Exception) { DebugLog("ERROR: Failed to initialize secondary authentication object."); } } AuthStateChanged(this, null); }
// Track state changes of the auth object. void AuthStateChanged(object sender, System.EventArgs eventArgs) { Firebase.Auth.FirebaseAuth senderAuth = sender as Firebase.Auth.FirebaseAuth; Firebase.Auth.FirebaseUser user = null; if (senderAuth != null) { userByAuth.TryGetValue(senderAuth.App.Name, out user); } if (senderAuth == auth && senderAuth.CurrentUser != user) { bool signedIn = user != senderAuth.CurrentUser && senderAuth.CurrentUser != null; if (!signedIn && user != null) { DebugLog("Signed out " + user.UserId); } user = senderAuth.CurrentUser; userByAuth[senderAuth.App.Name] = user; if (signedIn) { DebugLog("AuthStateChanged Signed in " + user.UserId); displayName = user.DisplayName ?? ""; DisplayDetailedUserInfo(user, 1); } } }
private void AuthFirebase() { Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance; Firebase.Auth.Credential credential = Firebase.Auth.FacebookAuthProvider.GetCredential(Facebook.Unity.AccessToken.CurrentAccessToken.TokenString); 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 user = auth.CurrentUser; if (user != null) { string name = user.DisplayName; string email = user.Email; System.Uri photo_url = user.PhotoUrl; // 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. string uid = user.UserId; SceneManager.LoadScene("SampleScene", LoadSceneMode.Single); } }); }
void InitializeFirebase() { console.text = "Setting up Firebase Auth"; auth = Firebase.Auth.FirebaseAuth.DefaultInstance; auth.StateChanged += AuthStateChanged; AuthStateChanged(this, null); }
void Awake() { auth = Firebase.Auth.FirebaseAuth.DefaultInstance; DatabaseManager.sharedInstance.GetReader(auth.CurrentUser.UserId, result => { Debug.Log(result.email); profilePanel.GetComponent <Profile>().Display(result); }); }
void Start() { errorText.SetActive(false); emailSignInException = ""; auth = Firebase.Auth.FirebaseAuth.DefaultInstance; resendOTPText.SetActive(false); resendOTPButton.SetActive(false); }
// Track ID token changes. void IdTokenChanged(object sender, System.EventArgs eventArgs) { Firebase.Auth.FirebaseAuth senderAuth = sender as Firebase.Auth.FirebaseAuth; if (senderAuth == auth && senderAuth.CurrentUser != null && !fetchingToken) { senderAuth.CurrentUser.TokenAsync(false).ContinueWithOnMainThread( task => DebugLog(String.Format("Token[0:8] = {0}", task.Result.Substring(0, 8)))); } }
public void SignOut() { auth = Firebase.Auth.FirebaseAuth.DefaultInstance; Debug.Log("user signed out and removed from remember-me option , need to enter credentials on the next app open"); PlayerPrefs.SetInt("rememberUserLogin", 0); auth.SignOut(); SceneManager.LoadScene("SignIn"); }
// DatabaseReference reference; // Start is called before the first frame update void Start() { auth = Firebase.Auth.FirebaseAuth.DefaultInstance; // Set up the Editor before calling into the realtime database. //FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://voter-41176.firebaseio.com/"); // Get the root reference location of the database. //reference = FirebaseDatabase.DefaultInstance.RootReference; }
void InitializeFirebase() { Debug.Log("Setting up Firebase Auth"); auth = Firebase.Auth.FirebaseAuth.DefaultInstance; reference = FirebaseDatabase.DefaultInstance.RootReference; StartCoroutine(CheckAutoLogin()); auth.StateChanged += AuthStateChanged; AuthStateChanged(this, null); }
void Awake() { //Setup for Google Sign In configuration = new GoogleSignInConfiguration { WebClientId = webClientId, RequestIdToken = true }; auth = Firebase.Auth.FirebaseAuth.DefaultInstance; }