示例#1
0
        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)));
        }
示例#2
0
        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();
        }
示例#3
0
        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;
        }
示例#4
0
        private async Task EnsureAuth()
        {
            if (this.auth == null)
            {
                this.auth = await AuthenticateAsync();

                return;
            }

            if (this.auth.Expires <= DateTime.UtcNow)
            {
                this.auth = await AuthenticateAsync(true);
            }
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }