public RegistroRequest Request(TwitchOAuthResponse twitchOAth) { return(new RegistroRequest { Code = twitchOAth.Code, UsuarioId = twitchOAth.UsuarioId.ToStringEmptyIfEmpty(), EmpresaId = twitchOAth.EmpresaId.ToStringEmptyIfEmpty(), ContaRedeSocial = twitchOAth.ContaRedeSocial }); }
public ResponseEnvelope RegistrarPerfil(TwitchOAuthResponse twitchOAth) { var parser = new RegistrarPerfil(); var request = parser.Request(twitchOAth); var response = client.RegistrarPerfil(request); var envelope = parser.Response(response); if (!envelope.Success) { throw new GRPCException(envelope.HttpStatusCode); } return(envelope); }
private async Task <string> CreateNewAccessToken() { string accessToken = null; httpClient = new HttpClient(); HttpResponseMessage results = await httpClient.PostAsync($"https://id.twitch.tv/oauth2/token?client_id={TwitchMonitor.API.Settings.ClientId}&client_secret={AppSettings.Settings["twitchClientSecret"]}&grant_type=client_credentials", new FormUrlEncodedContent(new KeyValuePair <string, string> [0])); if (!results.IsSuccessStatusCode) { Log.Error($"Attempt to get Twitch Access Token Failed for reason: {await results.Content.ReadAsStringAsync()}"); } else { TwitchOAuthResponse twitchResponse = JsonConvert.DeserializeObject <TwitchOAuthResponse>(await results.Content.ReadAsStringAsync()); Log.Information($"Twitch Access Token successfully retrieved"); accessToken = twitchResponse.access_token; } return(accessToken); }
public async static Task StartLiveMonitorAsync(DiscordSocketClient client) { _client = client; API = new TwitchAPI(); API.Settings.ClientId = AppSettings.Settings["twitchClientId"]; HttpResponseMessage results = await httpClient.PostAsync($"https://id.twitch.tv/oauth2/token?client_id={API.Settings.ClientId}&client_secret={AppSettings.Settings["twitchClientSecret"]}&grant_type=client_credentials", new FormUrlEncodedContent(new KeyValuePair <string, string> [0])); Log.Information($"Results: {results.ToString()}"); if (!results.IsSuccessStatusCode) { Log.Error($"Attempt to get Twitch Access Token Failed for reason: {await results.Content.ReadAsStringAsync()}"); } else { TwitchOAuthResponse twitchResponse = JsonConvert.DeserializeObject <TwitchOAuthResponse>(await results.Content.ReadAsStringAsync()); Log.Information($"Twitch Access Token successfully retrieved"); API.Settings.AccessToken = twitchResponse.access_token; } Monitor = new LiveStreamMonitorService(API, 15); await UpdateMonitorList(); await Task.Delay(-1); }
public TwitchRegistrarPerfil(TwitchOAuthResponse twitchOAuthResponse) { this.twitchOAuthResponse = twitchOAuthResponse; }