So this come back to the basic question, which Authentication type should we use…OAuthClientID or ServiceAccountKey ?
When you use Service Account, then the property AuthenticationType should be set to ServiceAccountKey: Activities - GSuite Application Scope
After you set up your Service Account, you’ll be able to download the JSON file that act as the key: Authenticate for using client libraries | Authentication | Google Cloud
From previous replies, OAuthClientID is suggested, but how about this issue?
The OAuth Client ID method works with all GSuite services, however it’s recommended for attended automation because user consent is required before the robot can access to your Google account.
Yes, when you use OAuth Client ID, the robot will use a user’s account, so the user is prompted to allow that. But it can access any resource available to the user without further configuration necessary.
Besides, while trying to Create Credentials OAuth2, What Application type should I choose? Authorized JavaScript origins? Authorized redirect URIs? and what should i put for user inArgurment ?
For the application type, choose “Other”.
I have created samples showing how use the three kinds of authentication, including detailed instructions on how to setup things on G Suite. Since I did it a few months ago, there might be a few differences, but it should be possible to get the main idea.
GSuiteActivitiesAPIKeySample.zip (3.5 KB)
GSuiteActivitiesOAuthSample.zip (11.2 KB)
GSuiteActivitiesServiceAccountSample.zip (11.4 KB)