void Setup(bool available) { if (available) { DeviceAuthenticationRequest request = new DeviceAuthenticationRequest(); request.Send(OnLoginSuccess); } }
//public void Register(string username, string email, string password) //{ // BacktoryUser NewUser = new BacktoryUser // { // Username = username, // Email = email, // Password = password // }; // NewUser.RegisterInBackground(response => // { // // Checking result of operation // if (response.Successful) // { // Debug.Log("Register Success; new username is " + response.Body.Username); // Login(username, password); // } // else if (response.Code == (int)BacktoryHttpStatusCode.Conflict) // { // // Username is invalid // Debug.Log("Bad username; a user with this username already exists."); // } // else if (response.Code == (int)BacktoryHttpStatusCode.NotFound) // { // // Username is invalid // Debug.Log("your authentication is wrong"); // } // else // { // // General failure // Debug.Log("Registration failed; for network or some other reasons: " + response.Code.ToString()); // } // }); //} public void RegisterAsGuest() { DeviceAuthenticationRequest user = new DeviceAuthenticationRequest(); user.Send((respone) => { if (!respone.HasErrors) { Debug.Log("ok"); SceneManager.LoadScene(0); } else { // Operation generally failed, maybe internet connection issue Debug.Log(respone.Errors.JSON.ToString()); } }); }
public void Authenticate(Action callback) { DeviceAuthenticationRequest request = new DeviceAuthenticationRequest(); request.Send( (resp) => { Debug.Log(resp.JSONString); UserId = resp.UserId; if (callback != null) { callback(); } }, (resp) => { Debug.LogError(resp.JSONString); } ); }
/// <summary> /// Log the user in as a guest. /// </summary> /// <param name="eventName">The event will be called after the device authentication response.</param> public static void DeviceAuthentication(string eventName) { Debug.Log("Device authentication..."); var deviceAuthenticationRequest = new DeviceAuthenticationRequest(); deviceAuthenticationRequest.Send(response => { if (!response.HasErrors) { Debug.Log("Player authenticated!\nName: " + response.DisplayName); EventManager.TriggerEvent(eventName, response.DisplayName); IsUserLoggedIn = true; } else { Debug.Log("Error authenticating player... \n" + response.Errors.JSON.ToString()); EventManager.TriggerEvent(eventName, ""); } }); }
/// <summary> /// Log the user in as a guest. /// </summary> /// <param name="eventName"></param> The event that will be called after the device authentication response public static void DeviceAuthentication(string eventName) { Debug.Log("Device authentication..."); Login(DataController.GetValue <string>("username"), DataController.GetValue <string>("LastValidPassword" + DataController.GetValue <string>("username")), null); //DataController.GetValue<string>("LastValidPassword" + DataController.GetValue<string>("username")); //DataController.SaveValue("username", ""); var deviceAuthenticationRequest = new DeviceAuthenticationRequest(); deviceAuthenticationRequest.Send(response => { if (!response.HasErrors) { GameSparks.Core.GSData GSList = response.ScriptData; foreach (var vg in GSList.GetGSDataList("VirtualGoodsList")) { foreach (string modifier in EqModifiers) { if (vg.GetGSData("currencyCosts").GetInt(modifier) != null) { DataController.SaveValue(vg.GetString("name") + modifier, (int)vg.GetGSData("currencyCosts").GetInt(modifier)); } } DataController.SaveValue(vg.GetString("name") + "Price", (int)vg.GetGSData("currencyCosts").GetInt("Bread")); DataController.SaveValue(vg.GetString("name") + "SellPrice", (int)vg.GetGSData("currencyCosts").GetInt("BreadPrice")); } foreach (string atributeName in ServerNamz) { DataController.SaveValue(atributeName + "Mine", 0); } foreach (string TypeItem in Equipment.ForInvLoad) { foreach (string Name in EquipmentNames) { DataController.SaveValue(Name + TypeItem + "ammount", 0); } } Debug.Log("Player autheticated!\nName: " + response.DisplayName); EventManager.TriggerEvent(eventName, response.DisplayName); IsUserLoggedIn = true; DataController.SaveValue("GSNotSynced" + DataController.GetValue <string>("username"), 0); DataController.SaveValue("Exp", 0); DataController.SaveValue("Bread", 0); DataController.SaveValue("SkillPoints", 0); DataController.SaveValue("Rating", 0); for (int i = 0; i < CelebrationAnimation.Prices.Count; i++) { DataController.SaveValue("WinAnimNumberMine" + i + "ammount", 0); } } else { Debug.Log("Error authenticating player... \n: " + response.Errors.JSON.ToString()); EventManager.TriggerEvent(eventName, ""); } }); }
/// <summary> /// Begin a new DeviceAuthenticationRequest /// </summary> /// <param name="requestData"></param> /// <returns>GameSparksAuthentication</returns> public GameSparksAuthenticationResponse DeviceAuthenticationRequest(DeviceAuthenticationRequest requestData) { return(DeserializeResponse(Requestor.PostString(Urls.DeviceAuthenticationRequest, SerializeRequest(requestData)).ResponseJson)); }
/// <summary> /// Begin a new asynchronous DeviceAuthenticationRequest /// </summary> /// <param name="requestData"></param> /// <returns>GameSparksAuthentication</returns> public async Task <GameSparksAuthenticationResponse> DeviceAuthenticationRequestAsync(DeviceAuthenticationRequest requestData) { var res = await Requestor.PostStringAsync(Urls.DeviceAuthenticationRequest, SerializeRequest(requestData)); return(DeserializeResponse(res.ResponseJson)); }