public static string CheckAccessToken(string accessToken) { NameValueCollection headers = new NameValueCollection(); headers.Add("Authorization", $"OAuth {accessToken}"); string response = GetPostWeb.Request("https://id.twitch.tv/oauth2/validate", "GET", "", null, headers); return(response); }
public Song CreateSongById(string idOrLink) { string id = GetIdByUrl(idOrLink); try { dynamic YouTubeInfo = JsonConvert.DeserializeObject(GetPostWeb.Request($"https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/watch?v={ id }", "GET", "", null)); return(new Song() { Index = 3, Id = id, YoutubeLink = $"https://www.youtube.com/watch?v={ id }", Title = YouTubeInfo["title"].ToString(), Image = new BitmapImage(new Uri(YouTubeInfo["thumbnail_url"].ToString())), IsSelected = false }); } catch (Exception e) { return(null); } }
/// <summary> /// You can get access tokens with out http server if you have twtich auth code /// </summary> /// <param name="code"></param> /// <returns></returns> public async Task <TwitchAuthResponse> TwitchAuthorizationApi(string code) { TwitchAuthResponse myAuthResponse = null; NameValueCollection postDataDictionary = new NameValueCollection(); postDataDictionary.Add("client_id", _twitchClientId); postDataDictionary.Add("client_secret", _twitchClientSecret); postDataDictionary.Add("grant_type", "authorization_code"); postDataDictionary.Add("redirect_uri", _twitchRedirectUri); postDataDictionary.Add("state", "123456"); postDataDictionary.Add("code", code); try { myAuthResponse = JsonConvert.DeserializeObject <TwitchAuthResponse>(await GetPostWeb.RequestAsync("https://api.twitch.tv/kraken/oauth2/token", "POST", postDataDictionary)); myAuthResponse.Code = code; } catch { // throw ex; } _transferTokensCallBack(myAuthResponse); return(myAuthResponse); }