public static async Task <TwitchAccessTokenModel> RefreshAccessToken(string token) { TwitchAccessTokenModel result = null; string apiPath = $"{_apiUrl}/oauth2/token"; apiPath += $"?client_id={ClientId}"; apiPath += $"&client_secret={ClientSecret}"; apiPath += $"&refresh_token={token}"; apiPath += "&grant_type=refresh_token"; HttpResponseMessage response = await client.PostAsync(apiPath, null); if (response.IsSuccessStatusCode) { result = await response.Content.ReadAsAsync <TwitchAccessTokenModel>(); } return(result); }
public static async Task <TwitchAccessTokenModel> GetAccessToken(string code, string redirectUrl) { TwitchAccessTokenModel result = null; string apiPath = $"{_apiUrl}/oauth2/token"; apiPath += $"?client_id={ClientId}"; apiPath += $"&client_secret={ClientSecret}"; apiPath += $"&code={code}"; apiPath += "&grant_type=authorization_code"; apiPath += $"&redirect_uri={redirectUrl}"; HttpResponseMessage response = await client.PostAsync(apiPath, null); if (response.IsSuccessStatusCode) { result = await response.Content.ReadAsAsync <TwitchAccessTokenModel>(); } return(result); }