Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Google Cloud Gmail service #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GeoffreyBooth
Copy link

In order to use a Google Cloud service account to send email via Gmail, you need to add the subject property when requesting the access token. Using googleapis, per googleapis/google-auth-library-nodejs#916 (comment), this is done via:

const auth = new google.auth.GoogleAuth({
  keyFile: 'google-cloud-credentials.json',
  scopes: [
    'https://www.googleapis.com/auth/gmail.send',
  ],
  clientOptions: {
    subject: '[email protected]',
  },
})

Something similar can almost be done with web-auth-library, however the subject option isn’t currently getting passed down from getAccessToken to createCustomToken. This PR adds it, and adds it to the type.

I also added a full example showing how to send an email via Google Cloud and Gmail. Apologies for the length. I’ve tested the code in that example using my own service account and it works.

I don’t have a Firebase account and I don’t think my Google Cloud service account has all the permissions necessary to run the test suite, so I didn’t try to add a test for this. Sorry. Hopefully this is a tiny enough change that you can accept it as is, or you can adapt my readme example into a new test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant