Answer:
You need to enable the APIs and provide scopes in three places: in your auth code, in the GCP console, and the Google Admin console.
More Information:
As I explained in the comments, the code you have provided should run without issue. The Insufficient Permission: Request had insufficient authentication scopes.
error is a result of the service account not being given access to the required scopes somewhere on Google’s side.
Make sure you have completed the following steps:
- Provided the scopes in the application as an auth object (which you have already done):
const auth = new GoogleAuth({
scopes: ['https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/compute']
});
- Enabled the Calendar API in the GCP console for your Service Account GCP Project.
- Provided the required scopes for your service account in the OAuth consent screen settings in GCP.
- Added the required scopes to the service account in the Google Admin console. This is done by following the
Security > Advanced Settings > Manage API client access
UI elements, and assigning all scopes the service account needs to the service account client ID.
Note: This final step must be done by a domain admin and can not be done by anyone who is not.
In this case, you will need to contact your domain admin to give your project API access.