npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bztes/strapi-provider-email-gmail-api

v4.0.3

Published

Strapi email provider for Gmail using googleapi and OAuth 2.0

Downloads

56

Readme

strapi-provider-email-gmail-api

Yet another Strapi email provider for Gmail using OAuth 2.0 ;)

Installation

It's required to install this package with a different alias so that it belongs to the @strapi scope.

# npm
npm i @strapi/provider-email-gmail-api@npm:@bztes/strapi-provider-email-gmail-api

# or yarn
yarn add @strapi/provider-email-gmail-api@npm:@bztes/strapi-provider-email-gmail-api

The package.json should then contain:

  "dependencies": {
    "@strapi/provider-email-gmail-api": "npm:@bztes/strapi-provider-email-gmail-api@^4.0.0",
  }

Preparing Google API

Enable the Gmail API with OAuth authentication in 5 steps

Create a new Project

  1. Open the Google Console
  2. Create a new Project

Enable Gmail API

  1. In the Google Console select 'APIs & Services' -> 'Library'
  2. Search for 'Gmail' and click on enable

Configure OAuth consent screen

  1. In the Google Console select 'APIs & Services' -> 'OAuth consent screen'
  2. Select User Type 'Internal'
  3. Provide an App name and email address and click on 'save and continue'
  4. Click on 'add or remove scope'
  5. Select 'Gmail API .../auth/gmail.send' and click on 'update' and then 'save and continue'

Add Credentials

  1. In the Google Console select 'APIs & Services' -> 'Credentials'
  2. Select 'create credentials' -> 'OAuth client ID'
  3. Select 'Web application' and provide a name
  4. For 'Authorized redirect URIs' add 'https://developers.google.com/oauthplayground'
  5. Click on 'create'
  6. Take the 'Client ID' and 'Client Secret'

Connect a Gmail account

  1. Open the Google OAuth 2.0 Playground
  2. Click on settings and select 'Use your own OAuth credentials'
  3. Enter your 'Client ID' and 'Client Secret' and click on 'close'
  4. In Step 1 select 'Gmail API v1' -> '.../gmail.send' and click on 'Authorize APIs'
  5. Authorize with your Gmail Account you want to send mails from
  6. In Step 2 click on 'Exchange authorization code for tokens'
  7. Click on Step 2 and take the 'Refresh Token'

Provider Configuration

| Variable | Type | Description | Required | Default | | --------------------------------- | ------ | ----------------------------------------------------------- | -------- | ------- | | provider | string | The name of this provider 'google' | yes | | | providerOptions | object | Provider options | yes | | | providerOptions.auth.userId | string | The mail address of the Google account to send e-mails from | yes | | | providerOptions.auth.clientId | string | OAuth 2.0 Client ID | yes | | | providerOptions.auth.clientSecret | string | OAuth 2.0 Client Secret | yes | | | providerOptions.auth.refreshToken | string | OAuth 2.0 Refresh Token | yes | | | settings | object | Settings | yes | | | settings.defaultFrom | string | Default sender mail address | no | | | settings.defaultReplyTo | string | The receiver is asked to reply to | no | |

Provider Configuration Example

config/plugins.js

module.exports = ({ env }) => ({
  email: {
    config: {
      provider: 'gmail-api',
      providerOptions: {
        auth: {
          userId: env('EMAIL_OAUTH2_USERID'),
          clientId: env('EMAIL_OAUTH2_CLIENTID'),
          clientSecret: env('EMAIL_OAUTH2_CLIENTSECRET'),
          refreshToken: env('EMAIL_OAUTH2_REFRESHTOKEN'),
        },
      },
      settings: {
        defaultFrom: env('EMAIL_FROM'),
        defaultReplyTo: env('EMAIL_REPLYTO'),
        testAddress: env('EMAIL_TEST_ADDRESS'),
      },
    },
  },
});

.env

EMAIL_FROM=Example Inc. <[email protected]>
EMAIL_REPLYTO=Example Inc. <[email protected]>
[email protected]
[email protected]
EMAIL_OAUTH2_CLIENTID=123....321.apps.googleusercontent.com
EMAIL_OAUTH2_CLIENTSECRET=ABC123...
EMAIL_OAUTH2_REFRESHTOKEN=1//123XYZ...

Resources