1

I'm trying to implement the API following this example: Use Google Analytics API to show information in C#

I have followed all the instructions and in fact I'm successful in being authenticated. When I get the list of accounts, I actually see the correct account/profile and I see that I have ALL permissions.

 var path = HostingEnvironment.MapPath("~/ServiceAccountProject-354a114cc3c1.p12");
 var email = "myemail@developer.gserviceaccount.com";


 GoogleConnector ga = new GoogleConnector(path,email );
 var accounts = ga.Service.Management.Accounts.List().Execute();

However, when I execute the next line to get the analytics data for that exact account that I have full permissions for, I get the error "Google.Apis.Requests.RequestError User does not have sufficient permissions for this profile. [403] Errors [Message[User does not have sufficient permissions for this profile.] Location[ - ] Reason[insufficientPermissions] Domain[global]]"

 var path = HostingEnvironment.MapPath("~/ServiceAccountProject-354a114cc3c1.p12");
 var email = "myemail@developer.gserviceaccount.com";


 GoogleConnector ga = new GoogleConnector(path,email );
 var accounts = ga.Service.Management.Accounts.List().Execute();
 var nuberOfPageViews = ga.GetAnalyticsData("ga:" + accounts.Items[0].Id, new string[] { "ga:pageviews" },
            DateTime.Now.AddDays(-1), DateTime.Now).Rows[0][0];

Please help!

Community
  • 1
  • 1
user19754
  • 51
  • 7
  • http://stackoverflow.com/questions/16944933/google-analytics-api-error-403-user-does-not-have-permission-to-access-profile – broguyman Jan 28 '15 at 18:32

1 Answers1

1

You are using the accounts.Items[0].Id when you need to be using the View (Profile) Id.

Try using the account explorer and you can see the difference between what makes an Account Id, Property Id, and View (Profile) Id.

Matt
  • 5,028
  • 2
  • 28
  • 55