Google analytics API .NET
嗨,我回复了这条消息
"Google.Apis.Auth.OAuth2.Responses.TokenResponseException' occurred in Google.Apis.dll
Additional information: Error:"invalid_grant", Description:"", Uri:""
这是我的代码
String serviceAccountEmail = "semanadev@gmail.com";
var certificate = new X509Certificate2("SiteViews-0c1a357186d9.p12", "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { AnalyticsService.Scope.AnalyticsReadonly }
}.FromCertificate(certificate));
AnalyticsService analyticsService = new Google.Apis.Analytics.v3.AnalyticsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "SiteViews"
});
GaData results = analyticsService.Data.Ga.Get("ga:72785204", "2014-10-10", "2014-10-20", "ga:users").Execute();