0
public void OAuthRedirect(string code)
{
    RestClient restClient = new RestClient();

    RestRequest request = new RestRequest(); 
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

    request.AddParameter("grant_type", "authorization_code");
    request.AddParameter("code", code);
    request.AddParameter("redirect_uri", ConfigurationManager.AppSettings["RedirectUrl"]);
    request.AddHeader("Authorization", string.Format(AuthorizationHeader));

    restClient.BaseUrl = Convert.ToString(new Uri("https://zoom.us/oauth/token"));
    //restClient.BaseUrl = new Uri("https://zoom.us/oauth/token");

    var response = restClient.Post(request); 

    if (response.StatusCode == System.Net.HttpStatusCode.OK)
    {
        System.IO.File.WriteAllText(ConfigurationManager.AppSettings["TokenFilePath"], response.Content);
        var token = JObject.Parse(response.Content);
        this.GetUserDetails(token["access_token"].ToString());

        //return RedirectToAction("Index", "Home");
    } 
    //return View("Error");
}

When I am trying to create a token using this code, I get an error:

The underlying connection was closed: An unexpected error occurred on send

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

-1

Add the below to your code:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77