当我想要获取访问令牌时,它将引发WebException。以下代码在6月21日之前获取访问令牌。在这段时间之后,它将引发WebException
var linkAccessToken = "https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code=" + code + "&redirect_uri=" + redirectUri + "&client_id=" + clientId + "&client_secret=" + clientSecret;
var request = (HttpWebRequest)WebRequest.Create(linkAccessToken);
request.ContentType = "application/json; charset=utf-8";
try
{
using (var response = request.GetResponse())
{
}
}
catch (WebException ex)
{
// ex.Status is WebExceptionStatus.SendFailure
}
答案 0 :(得分:2)
在创建请求之前使用以下代码!
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;