【发布时间】:2016-05-09 03:01:58
【问题描述】:
我正在使用 C# 从 Google 请求访问令牌:
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;
为了符合 PCI 规定,我不得不禁用 TLS 1.0。既然我已经这样做了,这段代码就会出现以下错误:
发生了一个或多个错误。:发送 请求。:底层连接已关闭:意外错误 接收时发生。:客户端和服务器无法通信, 因为他们没有共同的算法
关于如何使用 TLS 1.1+ 拨打电话的任何建议?
【问题讨论】:
-
看看这个link。它对此有很好的信息。
标签: google-analytics access-token tls1.2