Domain-wide delegated service account Oauth2.0 access for Gmail, Google Calendar in nodejs

Sorry if this is a re-post; I submitted this question earlier but I'm not seeing any record of it.

I think I want to follow these instructions but for nodejs, in order for my Domain-wide delegated service account to send emails and create calendar events on behalf of my workspace users from a nodejs web app hosted on an external server. 

I'm having a lot of difficulty with the JWT step, but from what I understand I need to create a JWT and use that to get an authorization token which I can add to my OAuth2Client instance using .setCredentials.

The OAuth2Client's clientId and clientSecret come from the OAuth2.0 Client Id I created for my web app. I also added an authorized redirectUri for completeness although I don't think it's relevant for this use case. 

I've tried too many variations on this strategy at this point and didn't document them thoroughly, but I'll edit this post later to include them and the errors they produce. 

In the meantime, I really appreciate any help.

0 2 560
2 REPLIES 2

mhawksey
Google Developer Expert
Google Developer Expert

I've not done specifically with NodeJS but researching this for another project I came across this post for Workspace user impersonation with NodeJS which sounded like it might help. 

 

This absolutely helped! Thank you so much.

Top Solution Authors