public async Task <TwitchChannel> GetUserAsync(string userId) { if (this.auth == null || this.auth.Expires <= DateTime.UtcNow) { this.auth = await AuthenticateAsync(); } return(JsonConvert.DeserializeObject <TwitchChannel>( await TwitchRequestAsync("https://api.twitch.tv/kraken/channels/" + userId, auth.access_token))); }
public async void StartTwitchApi() { myTwitchApi = new TwitchAuth(); await myTwitchApi.AuthCheck(); // await TaskEx.WaitUntil(myTwitchApi.HasToken); api = new TwitchAPI(); api.Settings.ClientId = myTwitchApi.ClientId(); api.Settings.AccessToken = myTwitchApi.Token(); StartChat(); }
public TwitchBot(IConfiguration config, ControlBus controlBus, ImageStore imageStore, SoundStore soundStore, TwitchAuth twitchAuth, ILogger <TwitchBot> logger) { _controlBus = controlBus; _imageStore = imageStore; _soundStore = soundStore; _twitchAuth = twitchAuth; _logger = logger; _twitchAuth.TokenSet += TwitchAuthOnTokenSet; }
private async Task EnsureAuth() { if (this.auth == null) { this.auth = await AuthenticateAsync(); return; } if (this.auth.Expires <= DateTime.UtcNow) { this.auth = await AuthenticateAsync(true); } }
public async Task <HttpClient> Connect() { TwitchApiCalls twitchCall = new TwitchApiCalls(); TwitchAuth bearer = await twitchCall.GetAuth().ConfigureAwait(false); var apiCall = new HttpClient { BaseAddress = new Uri("http://eshopfetcher.aspnet.pl/api/gamemodels") }; apiCall.DefaultRequestHeaders.Accept.Clear(); apiCall.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); return(apiCall); }
public async Task <HttpClient> Connect() { //Get bearer token TwitchApiCalls twitchCall = new TwitchApiCalls(); TwitchAuth bearer = await twitchCall.GetAuth().ConfigureAwait(false); //call address var apiCall = new HttpClient { BaseAddress = new Uri("https://api.igdb.com/v4/games") }; apiCall.DefaultRequestHeaders.Accept.Clear(); apiCall.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); apiCall.DefaultRequestHeaders.Add("Client-ID", "3yo2gt2qjjburcphl30wfyt0e64vxx"); apiCall.DefaultRequestHeaders.Add("Authorization", "Bearer " + bearer.Token); return(apiCall); }