我有一个ASP.NET 4.5应用程序,它有一个单独的类库,用于访问Google分析数据。每次尝试使用常用方法(从.p12文件加载证书)都以#34;内部错误"结束。 (该文件将被发现!)在第3行(Dim certificat ...)
Dim scopes As String() = New String() {AnalyticsService.Scope.Analytics}
Dim serviceAccountEmail = "info@xxx.biz"
Dim certificate = New X509Certificate2(System.Web.HttpContext.Current.Server.MapPath("Certificates/MyDashboard-b335c24b1a76.p12"), "notasecret", X509KeyStorageFlags.Exportable)
Dim credential = New ServiceAccountCredential(New ServiceAccountCredential.Initializer(serviceAccountEmail) With {.Scopes = scopes}.FromCertificate(certificate))
Dim service = New AnalyticsService(New BaseClientService.Initializer() With { _
.HttpClientInitializer = credential, _
.ApplicationName = "MyDashboard" _
})
Dim MyRequest As DataResource.GaResource.GetRequest = service.Data.Ga.Get("ga:44582845", "2016-01-01", "2016-01-01", "ga:sessions")
MyRequest.MaxResults = 1000
Dim MyResult As GaData = MyRequest.Execute()
[CryptographicException:Interner Fehler。 ] System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)+41 System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(字符串文件名,密码的IntPtr,UInt32的dwFlags中,布尔persistKeySet,SafeCertContextHandle&安培; pCertCtx)+0 System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName,Object password,X509KeyStorageFlags keyStorageFlags)+307 System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName,String password,X509KeyStorageFlags keyStorageFlags)+92 P:\ Google Analytics \ GoogleAnalyticsClient \ Class1.vb中的GoogleAnalyticsClient.Class1..ctor():59 preisvergleich.Statistik.Page_Load(Object sender,EventArgs e)位于\ web \ Webs \ AFFILIATE 2.0 \ preisvergleich \ Statistik.aspx.vb:16 System.EventHandler.Invoke(Object sender,EventArgs e)+0 System.Web.UI.Control.LoadRecursive()+ 71 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+3178
是否有可能在没有证书的情况下访问分析数据(我认为以前是这样)?
BR Jan