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

@zmiori/strapi-provider-email-gmail-2lo-v4

v4.0.2

Published

Gmail provider with 2-legged OAuth and a service account for the Strapi v4

Downloads

29

Readme

strapi-provider-email-gmail-2lo-v4

Strapi v4 version of the strapi-provider-email-gmail-2lo package.

This package is an email provider for the headless CMS Strapi. You can use this provider to send mail programmatically with @strapi/plugin-email.

This provider enables you to send email with the Gmail API using a 2-legged OAuth configuration, when using G Workspace.

Supported versions:

  • v4.x.x

Not having Google Workspace (previously G suite) will not work with this provider.

Installation

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

# using yarn
# npm
npm i @strapi/provider-email-gmail-2lo-v4@npm:@zmiori/strapi-provider-email-gmail-2lo-v4

# or yarn
yarn add @strapi/provider-email-gmail-2lo-v4@npm:@zmiori/strapi-provider-email-gmail-2lo-v4

The package.json should then contain:

  "dependencies": {
    "@strapi/provider-email-gmail-2lo-v4": "npm:@zmiori/strapi-provider-email-gmail-2lo-v4@^4.0.0",
  }

Setup

  1. Enable the Gmail API
  2. Configure the OAuth consent screen
  3. Create a service account
  4. Create a new Private key for your service account
  5. Configure the provider in config/plugins

| Variable | Type | Description | Required | Default | | ------------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- | | provider | string | The name of the provider you use | yes | | | providerOptions | object | Provider options | yes | | | providerOptions.username | string | An existing email address within your domain/project | yes | | | providerOptions.clientId | number | Service account API Client id | yes | | | providerOptions.privateKey| string | Service account private key | yes | | | settings | object | Settings | no | {} | | settings.defaultFrom | string | Default sender mail address, exist in domain | no | undefined | | settings.defaultReplyTo | string | array | Default address or addresses the receiver is asked to reply to | no | undefined |

Enable the scope in G Workspace (required)

The following steps will authorize the right scope, to allow sending email with G Workspace:

  1. Go to G Workspace admin dashboard > Security > API controls > Manage domain-wide delegation
  2. Add an authorized client
  • Client name: client_id
  • Scopes: https://mail.google.com/
  1. Authorize

Example

Path - config/plugins.js

module.exports = ({ env }) => ({
  // ...
  email: {
    config: {
      provider: 'gmail-2lo-v4',
    providerOptions: {
      username: '[email protected]',
      clientId: env('EMAIL_CLIENT_ID'),
      privateKey: env('EMAIL_PRIVATE_KEY').replace(/\\n/g, '\n'),
    },
    settings: {
      defaultFrom: '[email protected]',
      defaultReplyTo: '[email protected]',
    },
    }
  },
  // ...
});

TIP: When using environment variables for your privateKey, as in the example above, include all the \n in you .env file, like so:

EMAIL_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nAbC...xYz\n-----END PRIVATE KEY-----\n"

Resources

Links