Issue of accessing the Google Analytics API with C#.NET

497 views
Skip to first unread message

Dai Roger

unread,
Apr 23, 2013, 10:52:32 PM4/23/13
to google-analytics...@googlegroups.com
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!

Kamran Shahid

unread,
May 6, 2013, 9:44:57 AM5/6/13
to google-analytics...@googlegroups.com
Getting same error.
But this looks like a dead forum

Benjamin Canete

unread,
May 22, 2013, 8:56:53 PM5/22/13
to google-analytics...@googlegroups.com
Getting same error!
Don't know what it could be. Help please
Reply all
Reply to author
Forward
0 new messages