private void AuthSuccessful() { Debug.Log("Auth Successful1"); Firebase.Auth.FirebaseUser user = auth.CurrentUser; user.TokenAsync(true).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("TokenAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("TokenAsync encountered an error: " + task.Exception); return; } string idToken = task.Result; Debug.Log("User Token is :" + idToken); // Send token to your backend via HTTPS // ... }); Debug.Log("User TOoken Updated"); gameController.GetComponent <MainGameController>().ButtonGameControlPanel(); }
public void GetUserToken() { if (user == null) { DebugLog("Not signed in, unable to get token."); return; } DebugLog("Fetching user token"); user.TokenAsync(false).ContinueWith(HandleGetUserToken); }
public void LoginClick() { Firebase.Auth.Credential credential = Firebase.Auth.EmailAuthProvider.GetCredential(emailStr, passwordStr); Firebase.Auth.FirebaseAuth.DefaultInstance.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; Console.WriteLine("newUser={0}", newUser); newUser.TokenAsync(true).ContinueWith(idTokenTask => { if (idTokenTask.IsCanceled) { Debug.LogError("TokenAsync was canceled."); return; } if (idTokenTask.IsFaulted) { Debug.LogError("TokenAsync encountered an error: " + idTokenTask.Exception); return; } string idToken = idTokenTask.Result; UserSession userSession = new UserSession(); UserInfo userInfo = new UserInfo(new UserInfo.UserInfoBuilder().DisplayName(newUser.DisplayName).UserId(newUser.UserId)); userSession.SetUserInfo(userInfo); userSession.SetAuthToken(idToken); // TODO: DI for GameManager userSession.SetGameManager(new GameManager()); ClientContext.Instance.SetUserSession(userSession); SceneManager.LoadScene("HomeScene", LoadSceneMode.Single); }); }); }
public void TokenRefresh() { user.TokenAsync(true).ContinueWith(task => { if (task.IsCanceled) { Debug.Log("!!!!! TokenAsync was canceled."); return; } if (task.IsFaulted) { Debug.Log("!!!!! TokenAsync encountered an error: " + task.Exception); return; } string idToken = task.Result; Debug.Log("!!!!! Token: " + idToken); }); }
private void GenerateIDToken() { Firebase.Auth.FirebaseUser user = auth.CurrentUser; user.TokenAsync(true).ContinueWith(task => { if (task.IsCanceled) { Device.device.Log(0, "TokenAsync was canceled."); return; } if (task.IsFaulted) { Device.device.Log(0, "TokenAsync encountered an error: " + task.Exception); return; } string idToken = task.Result; Device.device.Log(1, idToken); Device.device.Log(1, "Firebase Current UserId: " + auth.CurrentUser.UserId + "Firebase UserId: " + user.UserId); }); }
public void setUserToken(String token) { Firebase.Auth.FirebaseUser user = auth.CurrentUser; user.TokenAsync(true).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("TokenAsync was canceled."); return; } if (task.IsFaulted) { Debug.LogError("TokenAsync encountered an error: " + task.Exception); return; } string idToken = task.Result; // Send token to your backend via HTTPS // ... }); userToken = token; Debug.Log("User TOoken Updated"); }