google-apigoogle-drive-apigoogle-admin-sdkgoogle-reporting-apigoogle-drive-shared-drive

Google G Suite Business Reports API configuration


I'm trying to configure Google Service Account (in developers console) to use it in my application to get Reports API.

I'm getting error - "Access denied. You are not authorized to read activity records". It seems some issue with configuration.

I created new Project and Service Account in Google Developers Console. Added Client ID in Admin Console Settings Manage API client access menu.

Maybe I missed something?

Please, help.

Server response is:

{
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "authError",
        "message": "Access denied. You are not authorized to read activity records.",
        "locationType": "header",
        "location": "Authorization"
      }
    ],
    "code": 401,
    "message": "Access denied. You are not authorized to read activity records."
  }
}

Solution

  • You can try to call the .setServiceAccountUser("admins email address") as per described in this SO post if you haven't done yet.