public static void Main(string[] args) { FortniteApi = new FortniteApiClient(Environment.GetEnvironmentVariable("APIKEY")); #if USE_EPICGAMES try { if (Database.TryGetValue("AccessToken", out string token) && Database.TryGetValue("RefreshToken", out string refreshToken)) { try { Epic = new EpicServices(token, refreshToken); } catch (EpicGamesException e) { Console.WriteLine(e.ErrorCode); Console.WriteLine(e.ErrorMessage); Epic = new EpicServices(GetSid(), OAuthService.AuthTokenType.LAUNCHER); } } else { Epic = new EpicServices(GetSid(), OAuthService.AuthTokenType.LAUNCHER); } } catch (EpicGamesException e) { Console.WriteLine(e.ErrorCode); Console.WriteLine(e.ErrorMessage); Epic = new EpicServices(GetSid(), OAuthService.AuthTokenType.LAUNCHER); } Database.SetValue("AccessToken", Epic.AccessToken); Database.SetValue("RefreshToken", Epic.RefreshToken); Console.WriteLine($"Authed as {Epic.Account.DisplayName}"); Scheduler.Default.Schedule(Epic.ExpiresAt.AddSeconds(-10), reschedule => { Epic.RefreshSession(); Database.SetValue("AccessToken", Epic.AccessToken); Database.SetValue("RefreshToken", Epic.RefreshToken); reschedule(Epic.ExpiresAt.AddSeconds(-10)); }); #else #warning The Epic Games auth is disabled #endif CreateHostBuilder(args).Build().Run(); }
private static void RegisterEvents(FortniteApiClient client) { client.XmppClient.Disconnected += () => { Log.Information("XMPP Disconnected"); return Task.CompletedTask; }; client.XmppClient.Connected += () => { Log.Information("XMPP Connected"); return Task.CompletedTask; }; client.XmppClient.NotificationReceived += e => { Log.Information("Received notification {Notification}", e.Type); return Task.CompletedTask; }; client.XmppClient.Ping += e => { Log.Information("Received ping by {Name} ({Id})", e.PingerDisplayName, e.PingerId); return Task.CompletedTask; }; client.XmppClient.PartyInvitation += async invitation => { Log.Information("Received party invitation from {FromId} Party: {PartyId}", invitation.SentBy, invitation.PartyId); try { await invitation.AcceptAsync(); } catch(Exception e) { Log.Fatal(e, "Something went wrong accepting the party invitation: {Message}", e.Message); return; } Log.Information("Successfully joined party."); }; client.XmppClient.PartyChatMessageReceived += e => { Log.Information("Received party chat message from {PartyId}. {From}: {Message}", e.Party.Id, e.From.Id, "Unknown."); return Task.CompletedTask; }; client.XmppClient.ChatMessageReceived += e => { Log.Information("Received chat message. {From}: {Message}", e.From, e.Message); return Task.CompletedTask; }; }
internal XmppClient(FortniteApiClient client, Platform platform) { Platform = platform; NotificationHandler = new XmppNotificationHandler(this); Client = client; Jid = $"{Client.CurrentLogin.AccountId}@prod.ol.epicgames.com"; Resource = $"V2:Fortnite:{platform.ToString().ToUpper()}:{Guid.NewGuid().ToString().Replace("-", "").ToUpper()}"; WebsocketClient = new ClientWebSocket(); WebsocketClient.Options.AddSubProtocol("xmpp"); WebsocketClient.Options.Credentials = new NetworkCredential { UserName = Jid, Password = Client.CurrentLogin.AccessToken }; WebsocketClient.Options.KeepAliveInterval = TimeSpan.FromSeconds(60); }
private static async Task Main() { var apiKey = string.Empty; // optional as of now. check https://dash.fortnite-api.com to be sure var api = new FortniteApiClient(apiKey); var metaTagsCosmetics = await api.V2.Cosmetics.SearchAllBrAsync(x => x.HasMetaTags = true); //var pak1002Cosmetics = await api.V2.Cosmetics.SearchAllBrAsync(x => x.DynamicPakId = "1002"); //var s16Cosmetics = await api.V2.Cosmetics.SearchAllBrAsync(x => x.BackendIntroduction = 16); //var newCosmetics = await api.V2.Cosmetics.GetBrNewAsync(); //var map = await api.V1.Map.GetAsync(); //var cosmeticsV2 = await api.V2.Cosmetics.GetBrAsync(); //var renegadeSearch = await api.V2.Cosmetics.SearchBrAsync(x => //{ // x.Name = "enegade raid"; // x.MatchMethod = MatchMethod.Contains; // x.BackendType = "AthenaCharacter"; //}); //var aesV2 = await api.V2.Aes.GetAsync(); //var aesV2Base64 = await api.V2.Aes.GetAsync(AesV2KeyFormat.Base64); //var newsV2 = await api.V2.News.GetAsync(); //var newsV2German = await api.V2.News.GetAsync(GameLanguage.DE); //var newsV2Br = await api.V2.News.GetBrAsync(); //var creatorCodeV2tfue = await api.V2.CreatorCode.GetAsync("tfue239042039480"); //var creatorCodeV2allStw = await api.V2.CreatorCode.SearchAllAsync("stw"); //var shopV2 = await api.V2.Shop.GetBrAsync(); //var shopV2German = await api.V2.Shop.GetBrAsync(GameLanguage.DE); var shopV2Combined = await api.V2.Shop.GetBrCombinedAsync(); //var statsV2V1 = await api.V1.Stats.GetBrV2Async(x => //{ // //x.AccountId = "4735ce9132924caf8a5b17789b40f79c"; // x.Name = "ninja"; // x.ImagePlatform = BrStatsV2V1ImagePlatform.All; //}); Debugger.Break(); }
internal BaseService(FortniteApiClient client) { Client = client; RestClient = client.CreateRestClient(this); }
internal FortniteService(FortniteApiClient client) : base(client) { }
/// <summary> /// fortite mor lioke fartnite am i righe or am i righe /// </summary> /// <param name="apiKey">the key to use</param> public void MakeSureApiIsSet() { _api = new FortniteApiClient(Config.FApiToken); }
internal AccountPublicService(FortniteApiClient client) : base(client) { }
public PartyService(FortniteApiClient client) : base(client) { }