我使用C#从谷歌请求访问令牌:谷歌Analytics(分析)访问令牌 - TLS 1.1+
string serviceAccountEmail = ConfigurationManager.AppSettings["analyticsServiceAccountEmail"].ToString();
string securityKey = ConfigurationManager.AppSettings["analyticsSecurityKeyLocation"].ToString();
string password = ConfigurationManager.AppSettings["analyticsSecurityPassword"].ToString();
var certificate = new X509Certificate2(securityKey, password, X509KeyStorageFlags.Exportable);
var scopes = new List<string> { "https://www.googleapis.com/auth/analytics.readonly", "https://www.googleapis.com/auth/analytics" };
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = scopes
}.FromCertificate(certificate));
Task<bool> task = credential.RequestAccessTokenAsync(CancellationToken.None);
task.Wait();
if (!task.Result || credential.Token == null || string.IsNullOrEmpty(credential.Token.AccessToken))
{
throw new Exception("Failed to get token from Google");
}
return credential.Token.AccessToken;
我不得不禁用TLS 1.0 PCI合规性。既然我已经做了,该代码与以下错误打破:
One or more errors occurred.: An error occurred while sending the request.: The underlying connection was closed: An unexpected error occurred on a receive.: The client and server cannot communicate, because they do not possess a common algorithm
任何建议,我怎么可以让使用TLS 1.1或更高版本的电话吗?
查看此[链接](https://github.com/LindaLawton/Google-Dotnet-Samples/tree/master/Google-Analytics)。它有很好的信息。 –