I am trying to access my Google Analytics using the following Laravel library:
"https://github.com/spatie/laravel-analytics"
I have created a service account on https://console.cloud.google.com/ and enabled google analytics API and Google analytics Data API services as shown below

I have also added the service account I created and given it a Viewer role in my google analytics account to be able to access the data as shown below
Following the instructions at the library github page, (https://github.com/spatie/laravel-analytics) I have downloaded the credentials.json and added it to
app/analytics/service-account-credentials.php and the content of my service-account-credentials.php is as follows:
{
"type": "service_account",
"project_id": "the-id-of-the-account",
"private_key_id": "e5cfe7ee29e6dc****6f288bc02ba27ef35e",
"private_key": "-----BEGIN PRIVATE KEY-----
\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQChqXfMtBJy/Oit\n663vhnxhiJIhyN5jdm+26yE5ItTAj/fKsbbmoVP7mNxloqfErUBxXo1wMYCb51U1\nXiiffFFlSmMNqIN9rU9RrT0ISCOjdjyb9aoX+Kz5QjiSn1W7OUaJqXvwLipOp180\nvQggvhI6wyUNeji5bdH9NoDCyQrLfZ9XSEnKXyiYC/J+2onHN7OsBfVbsZpbiXWf\nuEIE0oVgoEipSQiIM+pHADymRmJTzRfJK8ynDi2eC8Ja4kf+YXN21POA9iG5tVYr\ns3zoddzlvk1RdyiNJmszshsJQdzoUxsXCSpv8t94DMaYgo8iPgazi31zygTsyVol\nPoYo\nwJDMzdGnpA0mkoRutbi/6arcg857RDcwIz7vqeS8LEq2FCJxvxaBx0fEmG1GnC0i\nMh2AH3Ptc73iEopGyxtA+Lk4+JltjnVKWO2hfFEqtnr/T1OZpk/DqNxPXp9z5dtz\nZKMoq05c39R6pk7WCY1OTXuvlwKBgQDGOCwMV5n4AOoAYZhweIvHxRPEvS5jdNJi\nXg5O6eTSkDGl/RdCEhxSefHuQhV55TympHAoS3yHpinqSbmpsuD68Iam0qPpqRM1\nFGs7DKV/m2tTW6Y6HPsOGxeLC/nmpjKvjP+QBhRwh3Xpc/sybymfJNUuS/2/dhaC\nE3CmYDCUkwKBgA1cc7V9jVvzWf5ffnJpMFsK6NnTk8veIH99PZ96cqa+AJ6+1NFN\n0B9CPhMUuotAapvg4K3ZdOxN3OBh6jl//4dNe/u8JnCrQxIYuVvFDwVoU1lBfpwN\naNemvwL+voxMJUt16zDYQ5EIuyeNlCekTxSxMcibwls+/ViRL+vM5ZdtAoGAdakm\nTHU7igFQ5cUI7cpAfua3I1OA07ymnYljSOiB0ZOSRQuE4M1LTpHgUCOeB+tRI0H8\n6Y5Vb1ftDYuRz+/EqHBaHXBvp+Wa5ykltbl+C88/2A1RELHfPLJMOVd0kbsZ3yb9\nFIrnWxytm1QjSf6+YB9HA+JLz3jTR4cumTQD4k0CgYAZH0MkuUxwYlO4ddf6IKRY\n6cVs9pYlf0FuSNlusE3xFESJkuh0t48e/2Zq2HXXxTKU3nxDfd3r8IG/AtZH/qzy\nqi0ZwGWr2QmAM78E6EcrP/4O5jW6Tj7ILxNkO67ZQtL6HLK50xQ6+epoNCZHoRhZ\nPg0LBgee115+ziwL/wqujQ==\n-----END PRIVATE KEY-----\n",
"client_email": "the-service-account-email",
"client_id": "109033*****450598",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url":
"https://www.googleapis.com/robot/v1/metadata/x509/****tal.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
In config/analytics.php, I have the following configurations
<?php
return [
/*
* The view id of which you want to display data.
*/
'view_id' => env('ANALYTICS_VIEW_ID'),
/*
* Path to the client secret json file. Take a look at the README of this package
* to learn how to get this file. You can also pass the credentials as an array
* instead of a file path.
*/
'service_account_credentials_json' => app_path('analytics/service-account-credentials.json'),
/*
* The amount of minutes the Google API responses will be cached.
* If you set this to zero, the responses won't be cached at all.
*/
'cache_lifetime_in_minutes' => 60 * 24,
/*
* Here you may configure the "store" that the underlying Google_Client will
* use to store it's data. You may also add extra parameters that will
* be passed on setCacheConfig (see docs for google-api-php-client).
*
* Optional parameters: "lifetime", "prefix"
*/
'cache' => [
'store' => 'file',
],
];
I have the the value of the property ID added as ANALYTICS_VIEW_ID in my .env file.
However, when I try to call the API to get the analytics data, I get the following error
User does not have sufficient permissions for this profile
Please how can I resolve this issue

