小编Ben*_*ams的帖子

尝试访问谷歌分析时指定的提供程序类型无效

每当我们尝试访问 API 以获取当前用户编号时,我们都会收到以下错误。我已经尝试了几件事,但无法深入了解这一点。任何人都可以阐明什么是错误/缺失的吗?

我应该指出,因此在我的本地 PC 上运行得非常好,但在服务器上却失败了。

这是错误:

ConnectToAnalytics 错误:System.Security.Cryptography.CryptographicException:指定的提供程序类型无效。在 System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters 参数, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle System.safeKeyHandle) .Cryptography.RSACryptoServiceProvider.GetKeyPair() at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize) at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey() at Google.Apis. OAuth2.ServiceAccountCredential.Initializer。

当我运行代码时抛出此错误:

Public Shared Function GetRealtimeUsers() As String
    Try
        'realtime on site
        Dim gsService As AnalyticsService = Core.ConnectToAnalytics
        Dim RequestRealtime As DataResource.RealtimeResource.GetRequest = gsService.Data.Realtime.[Get]([String].Format("ga:{0}", "xxxxx"), "rt:activeUsers")
        Dim feed As RealtimeData = RequestRealtime.Execute()

        Return Int(feed.Rows(0)(0)).ToString()
    Catch ex As Exception
        Return "QUOTA USED"
    End …
Run Code Online (Sandbox Code Playgroud)

asp.net google-api google-analytics-api google-api-dotnet-client service-accounts

3
推荐指数
1
解决办法
1568
查看次数