Below is my samole.
BaseClientService.Initializer init = new BaseClientService.Initializer();
init.ApiKey = "AIzaSyDsqPJ5VDpj0xNe2XGXXXXgmlSWu81Wa_A";
const string ServiceAccountId = "
99351066XXXX.apps.googleusercontent.com";
const string ServiceAccountUser = "
993510...@developer.gserviceaccount.com";
AssertionFlowClient client = new AssertionFlowClient(
GoogleAuthenticationServer.Description, new X509Certificate2(@"a1a4140023ddae22d4e43c5e8d4f53e944563d8c-privatekey.p12", "notasecret", X509KeyStorageFlags.Exportable))
{
Scope = AnalyticsService.Scopes.AnalyticsReadonly.GetStringValue(),
ServiceAccountUser =ServiceAccountUser
,
ServiceAccountId = ServiceAccountId
};
OAuth2Authenticator<AssertionFlowClient> authenticator = new OAuth2Authenticator<AssertionFlowClient>(client, AssertionFlowClient.GetState);
//authenticator.LoadAccessToken();
init.Authenticator = authenticator;
AnalyticsService analyticsService = new AnalyticsService(init);
string profileId = "ga:4036XXXX";
string startDate = "2012-10-01";
string endDate = "2013-10-31";
string metrics = "ga:visits";
DataResource.GaResource.GetRequest request = analyticsService.Data.Ga.Get(profileId, startDate, endDate, metrics);
request.Dimensions = "ga:date";
GaData data = request.Fetch();
error "Error occurred while sending a direct message or getting the response."Who can help me
resolve this?
Thanks!