internal static void LoginWithRememberedSession(AssetStoreClient.DoneLoginCallback callback) { if (AssetStoreClient.sLoginState == AssetStoreClient.LoginState.IN_PROGRESS) { DebugUtils.LogWarning("Tried to login with remembered session while already in progress of logging in"); return; } AssetStoreClient.sLoginState = AssetStoreClient.LoginState.IN_PROGRESS; AssetStoreClient.sLoginErrorMessage = null; if (!AssetStoreClient.RememberSession) { AssetStoreClient.SavedSessionID = string.Empty; } Uri address = new Uri(string.Format("{0}/login?reuse_session={1}&unityversion={2}&toolversion={3}&xunitysession={4}", new object[] { AssetStoreClient.AssetStoreUrl, AssetStoreClient.SavedSessionID, Uri.EscapeDataString(Application.unityVersion), Uri.EscapeDataString("V4.1.0"), "26c4202eb475d02864b40827dfff11a14657aa41" })); AssetStoreWebClient assetStoreWebClient = new AssetStoreWebClient(); AssetStoreClient.Pending pending = new AssetStoreClient.Pending(); pending.conn = assetStoreWebClient; pending.id = "login"; pending.callback = AssetStoreClient.WrapLoginCallback(callback); AssetStoreClient.pending.Add(pending); assetStoreWebClient.Headers.Add("Accept", "application/json"); assetStoreWebClient.DownloadStringCompleted += AssetStoreClient.DownloadStringCallback; try { assetStoreWebClient.DownloadStringAsync(address, pending); } catch (WebException ex) { pending.ex = ex; AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; } }
internal static void LoginWithCredentials(string username, string password, bool rememberMe, AssetStoreClient.DoneLoginCallback callback) { if (AssetStoreClient.sLoginState == AssetStoreClient.LoginState.IN_PROGRESS) { DebugUtils.LogWarning("Tried to login with credentials while already in progress of logging in"); return; } AssetStoreClient.sLoginState = AssetStoreClient.LoginState.IN_PROGRESS; AssetStoreClient.RememberSession = rememberMe; AssetStoreClient.sLoginErrorMessage = null; Uri address = new Uri(string.Format("{0}/login", AssetStoreClient.AssetStoreUrl)); AssetStoreWebClient assetStoreWebClient = new AssetStoreWebClient(); NameValueCollection nameValueCollection = new NameValueCollection(); nameValueCollection.Add("user", username); nameValueCollection.Add("pass", password); nameValueCollection.Add("unityversion", Application.unityVersion); nameValueCollection.Add("toolversion", "V4.1.0"); nameValueCollection.Add("license_hash", AssetStoreClient.GetLicenseHash()); nameValueCollection.Add("hardware_hash", AssetStoreClient.GetHardwareHash()); AssetStoreClient.Pending pending = new AssetStoreClient.Pending(); pending.conn = assetStoreWebClient; pending.id = "login"; pending.callback = AssetStoreClient.WrapLoginCallback(callback); AssetStoreClient.pending.Add(pending); assetStoreWebClient.Headers.Add("Accept", "application/json"); assetStoreWebClient.UploadValuesCompleted += AssetStoreClient.UploadValuesCallback; try { assetStoreWebClient.UploadValuesAsync(address, "POST", nameValueCollection, pending); } catch (WebException ex) { pending.ex = ex; AssetStoreClient.sLoginState = AssetStoreClient.LoginState.LOGIN_ERROR; } }