I trying to implement an Server Node App which access the groups from Google Workspace to make some stuff.
I read some articles, Google doc and read some stack overflow questions but I still don't understand how this works
What I've done so far:
1 - I followed the instructions to give wide domain delegation to my service account
2 - I used service account information to generate google auth credentials
const { google } = require('googleapis');
const auth = new google.auth.JWT(
'serviceacount@email',
null,
'-----BEGIN PRIVATE KEY-----...',
'https://www.googleapis.com/auth/admin.directory.groups',
'myemail'
);
3 - With these auth, I'm trying to read the groups
async function main() {
const admin = await google.admin({
version: 'directory_v1',
auth,
});
console.log(await admin.groups.list({customer: 'XXXXX'}));
}
main();
But I get this error Error: invalid_grant: Invalid email or User ID
I don't understand what I'm getting wrong. Someone could help what can possibly be the cause of this problem? Because I setup everything as Wide Domain Tutorial and still get this error
Could be anything more ?