CSharp .NET Starting Point

Has any one been able to make an API request with a simple C# Console app? I found this example a while ago but it didn’t show how to get ‘AuthKey’, I’m assuming its from a call to /authCode but when I run it I get an error something like “the underlying connection was closed… an existing connection was forcibly closed by the remote host”

static async Task Main(string[] args)

		string authKey = await GetAuthKey();
		string token = await GetToken(authKey);

	private static async Task<string> GetAuthKey(){
		HttpClient client = new HttpClient();
		var request = new HttpRequestMessage(HttpMethod.Post, "https://api.tcgplayer.com/app/authorize/authCode");
		var formData = new List<KeyValuePair<string, string>>();
		formData.Add(new KeyValuePair<string, string>("Accept", "application/json"));
		request.Content = new FormUrlEncodedContent(formData);
		HttpResponseMessage response = await client.GetAsync("");
		string resultData = response.Content.ReadAsStringAsync().Result;
		return resultData;
	private static async Task<string> GetToken(string authKey)
		HttpClient client = new HttpClient();
			   .Add(new MediaTypeWithQualityHeaderValue("application/json")); //ACCEPT header
		client.DefaultRequestHeaders.Add("X-Tcg-Access-Token", authKey);

		StringContent postData =
			new StringContent(

		var result = await client.PostAsync("https://api.tcgplayer.com/", postData).ConfigureAwait(false);

		if (result.IsSuccessStatusCode)
			var respData = await result.Content.ReadAsStringAsync();
			JsonSerializerSettings settings = new JsonSerializerSettings();
			settings.MissingMemberHandling = MissingMemberHandling.Error;

			TcgAccessToken AccessToken = JsonConvert.DeserializeObject<TcgAccessToken>(respData, settings);
			throw new TcgApiException()
				StatusCode = result.StatusCode,
				Headers = result.Headers,
				ReasonPhrase = result.ReasonPhrase,
				RequestMessage = result.RequestMessage,
				IsSuccessStatusCode = result.IsSuccessStatusCode
		return "";

Got it to work! It was an issue with .NET security protocols. Added this line to my Main() method

System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;