public void OnLogoutClicked() { UnlinkSilentAuth(); ClearRememberMe(); AuthType = Authtypes.None; SigninPanel.SetActive(true); SigninSuccessPanel.SetActive(false); }
public void Awake() { if (ClearPlayerPrefs) { UnlinkSilentAuth(); ClearRememberMe(); AuthType = Authtypes.None; } RememberMeUI.isOn = RememberMe; RememberMeUI.onValueChanged.AddListener((toggle) => { RememberMe = toggle; }); }
public void Link(Authtypes authType) { switch (authType) { case Authtypes.Google: AuthType = authType; PlayFabClientAPI.LinkGoogleAccount(new LinkGoogleAccountRequest() { ServerAuthCode = AuthTicket, ForceLink = ForceLink }, (result) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, null); } }, (error) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, error); } }); break; case Authtypes.Facebook: AuthType = authType; PlayFabClientAPI.LinkFacebookAccount(new LinkFacebookAccountRequest() { AccessToken = AuthTicket, ForceLink = ForceLink }, (result) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, null); } }, (error) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, error); } }); break; } }
private void OnPlayfabFacebookAuthComplete(LoginResult result) { // Store identity and session _playFabId = result.PlayFabId; _sessionTicket = result.SessionTicket; RememberMeId = Guid.NewGuid().ToString(); AuthType = Authtypes.FaceBook; // Fire and forget, but link a custom ID to this PlayFab Account. PlayFabClientAPI.LinkCustomID( new LinkCustomIDRequest { CustomId = RememberMeId, ForceLink = ForceLink }, null, // Success callback null // Failure callback ); OnLoginSuccess(result); }
/// <summary> /// Kick off the authentication process by specific authtype. /// </summary> /// <param name="authType"></param> public void Authenticate(Authtypes authType) { AuthType = authType; Authenticate(); }
private void AddAccountAndPassword() { SilentlyAuthenticate( (LoginResult result) => { if (result == null) { //something went wrong with Silent Authentication, Check the debug console. OnPlayFabError(new PlayFabError() { Error = PlayFabErrorCode.UnknownError, ErrorMessage = "Silent Authentication by Device failed" }); } Debug.Log(result.PlayFabId); // Now add our username & password. PlayFabClientAPI.AddUsernamePassword( new AddUsernamePasswordRequest() { Username = result.PlayFabId, Email = UsernameUI.text, Password = PasswordUI.text, }, // Success (AddUsernamePasswordResult addResult) => { // Store identity and session _playFabId = result.PlayFabId; _sessionTicket = result.SessionTicket; // If they opted to be remembered on next login. if (RememberMe) { // Generate a new Guid RememberMeId = Guid.NewGuid().ToString(); // Fire and forget, but link the custom ID to this PlayFab Account. PlayFabClientAPI.LinkCustomID( new LinkCustomIDRequest() { CustomId = RememberMeId, ForceLink = ForceLink }, null, null ); } // Override the auth type to ensure next login is using this auth type. AuthType = Authtypes.EmailAndPassword; // Report login result back to subscriber. OnLoginSuccess(result); }, // Failure (PlayFabError error) => { //Report error result back to subscriber OnPlayFabError(error); }); }); }
private void AuthenticateEmailPassword() { if (RememberMe && !string.IsNullOrEmpty(RememberMeId)) { PlayFabClientAPI.LoginWithCustomID( new LoginWithCustomIDRequest() { TitleId = PlayFabSettings.TitleId, CustomId = RememberMeId, CreateAccount = true, InfoRequestParameters = InfoRequestParams }, //Success (LoginResult result) => { _playFabId = result.PlayFabId; _sessionTicket = result.SessionTicket; OnLoginSuccess(result); }, //Failure (PlayFabError error) => { OnPlayFabError(error); } ); return; } if (string.IsNullOrEmpty(UsernameUI.text) && string.IsNullOrEmpty(PasswordUI.text)) { OnDisplayAuthentication(); return; } PlayFabClientAPI.LoginWithEmailAddress( new LoginWithEmailAddressRequest() { TitleId = PlayFabSettings.TitleId, Email = UsernameUI.text, Password = PasswordUI.text, InfoRequestParameters = InfoRequestParams }, // Success (LoginResult result) => { // Store identity and session _playFabId = result.PlayFabId; _sessionTicket = result.SessionTicket; // If RememberMe is checked, then generate a new Guid for Login with CustomId. if (RememberMe) { RememberMeId = Guid.NewGuid().ToString(); AuthType = Authtypes.EmailAndPassword; // Fire and forget, but link a custom ID to this PlayFab Account. PlayFabClientAPI.LinkCustomID( new LinkCustomIDRequest { CustomId = RememberMeId, ForceLink = ForceLink }, null, // Success callback null // Failure callback ); } OnLoginSuccess(result); }, // Failure (PlayFabError error) => { OnPlayFabError(error); }); }
private void Authenticate(Authtypes auth_type) { AuthType = auth_type; Authenticate(); }
/// <summary> /// Linking for auth types /// </summary> /// <param name="authType"></param> public void Link(Authtypes authType) { switch (authType) { case Authtypes.Google: AuthType = authType; PlayFabClientAPI.LinkGoogleAccount(new LinkGoogleAccountRequest() { ServerAuthCode = AuthTicket, ForceLink = ForceLink }, (result) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, null); } }, (error) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, error); } }); break; case Authtypes.Facebook: AuthType = authType; PlayFabClientAPI.LinkFacebookAccount(new LinkFacebookAccountRequest() { AccessToken = AuthTicket, ForceLink = ForceLink }, (result) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, null); } }, (error) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, error); } }); break; case Authtypes.Xbox: AuthType = Authtypes.Xbox; PlayFabClientAPI.LinkXboxAccount(new LinkXboxAccountRequest() { XboxToken = AuthTicket, ForceLink = ForceLink }, (result) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, null); } }, (error) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, error); } }); break; case Authtypes.Steam: AuthType = Authtypes.Steam; PlayFabClientAPI.LinkSteamAccount(new LinkSteamAccountRequest() { SteamTicket = AuthTicket, ForceLink = ForceLink }, (result) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, null); } }, (error) => { if (OnPlayFabLink != null) { OnPlayFabLink.Invoke(authType, error); } }); break; case Authtypes.PSN: //TODO: how do we handle PSN in the sdks? //This might need to be generated. break; case Authtypes.OpenId: AuthType = Authtypes.OpenId; break; } }