0

I am trying to create a simple node app and I using service account to automate the OAuth Flow. While am able to successfully do this, am not able to retrieve the report from Google Analytics using this service account. I get the following error message,

{
  "error": {
    "code": 403,
    "message": "User does not have any Google Analytics account.",
    "status": "PERMISSION_DENIED"
  }
}

I can't add this service account to the Analytics account as my owner account (under which I created this service account) has only read-only access. So how do I proceed? How can I grant this service account the same read-only access as my owner account? When I login into Google Analytics using my owner account, I am not able to perform any User Management as it has limited access.

Please help me on how to proceed here.

Thanks

Karthik
  • 315
  • 1
  • 4
  • 17

2 Answers2

1

If using a service account, there is no way to proceed other than finding someone with user management permissions and have him add the account.

It is hard to see why you would expect it to be otherwise; the purpose of the permission system is to prevent unauthorized access, and it would do a pretty poor job if it suddenly allowed you to exceed your privileges by adding a user.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
Eike Pierstorff
  • 31,996
  • 4
  • 43
  • 62
  • I don't want it to grant me permission to add an account. I want to grant the same readonly access to service account as my owner account. – Karthik Jun 08 '17 at 04:41
  • Actually you do want permission to add another user to the account. From the point of view of the Google Account a service account is just another user, and you lack the privileges to add users. So you cannot add a service account. – Eike Pierstorff Jun 08 '17 at 05:43
0

As per the answer from Eike, you cannot add a Service Account if you lack the permissions to do so.

There is an alternative approach which allows you to use your own account, i.e. no service accounts anywhere. This basically involves you obtaining a Refresh Token, and using that to authenticate your access. You can follow the steps at How do I authorise an app (web or installed) without user intervention? (canonical ?) to do this.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115