By connecting your personal Gmail account to Pipedream, you'll be able to incorporate email into whatever you're building with any of the thousands of apps that are available on Pipedream.
import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
gmail: {
type: "app",
app: "gmail",
}
},
async run({steps, $}) {
return await axios($, {
url: `https://www.googleapis.com/oauth2/v1/userinfo`,
headers: {
Authorization: `Bearer ${this.gmail.$auth.oauth_access_token}`,
},
})
},
})
To connect your Gmail account to Pipedream, just accept the prompt when connecting your Gmail account. To connect your account with your own OAuth client, see below.
To get started, you'll need the following:
For detailed instructions, follow the steps below.
Sign in to the Google Cloud Console
Select an existing project, or create a new one
Select an existing project or create a new one in the Google Cloud Console
Select APIs & Services
Click Enable APIs & Services
Select "Enable APIs & Services to open a menu to enable the Gmail API for Pipedream to connect to
Search for and select Gmail API
Click Enable
Search for and select the Gmail Enterprise API
Search for and select Cloud Pub/Sub API
Click Enable
Search for and select the Cloud Pub/Sub API
Note: If you encounter issues with API enablement, ensure you have the necessary permissions in your Google Cloud project.
Click OAuth consent screen on the left side
Click "OAuth consent screen" in the left navigation menu
Set up the OAuth consent screen:
email, profile, https://www.googleapis.com/auth/gmail.modify, https://www.googleapis.com/auth/gmail.settings.basicSelect "External" in the OAuth Consent Screen
Navigate to the Credentials section on the left side.
Open the Credentials menu in the left hand nav bar
Click Create Credentials at the top and select OAuth client ID
Click create credentials to start the process
Select the OAuth Client ID option
Select Web application for Application type
Web application is the type of OAuth credential we're generating
Name the app, e.g. "Pipedream".
In a new window, navigate to the Accounts page in Pipedream, and click OAuth Clients.
Custom OAuth Client creation on Pipedream
Click New OAuth Client, and search for Gmail.
Name your OAuth Client, and click Continue.
Copy the Redirect URI, and return to your previous window.
On your Google Cloud app configuration page, click Add URI and paste the Redirect URI from the previous step.
Add the Pipedream URL to the Callback Redirect URL option
Click Create to create your new OAuth keys.
Store the Client ID and Client Secret keys
Copy the Client ID and Client Secret, and paste them in your OAuth Client configuration on Pipedream.
Custom OAuth Client creation on Pipedream
Important: When creating the OAuth client ID, make sure to copy the Redirect URI from Pipedream exactly as shown to avoid authentication errors.
Navigate to Credentials under APIs & Services, and click Create Credentials > Service Account.
Service Account Creation
Add a name and description for your service account, and grant the service account the role Pub/Sub Admin, and click Done.
Role administering
Click on the service account that you created, and click Keys > Add Key > Create New Key > JSON. This will download the service account JSON credentials to your computer. Be sure to save this securely.
Create private key
Google has a 7 day expiration window on refresh tokens for External applications with a publishing status of "Testing", so you will need to Publish your application in order to maintain your account connection.
Publish your application
Confirmation of changes
Emit new event for each attachment in a message received. This source is capped at 100 max new messages per run.
Emit new event when an email matching the search criteria is received. This source is capped at 100 max new messages per run.
Emit new event for each new email sent. (Maximum of 100 events emited per execution)
Add label(s) to an email message. See the docs
Suspend the workflow until approved by email. See the documentation
Archive an email message. See the documentation
Create a draft from your Google Workspace email account. See the documentation
Create a new label in the connected account. See the documentation
If you continue to experience issues, please contact Pipedream support for further assistance.
Gmail uses OAuth authentication. When you connect your Gmail account, Pipedream will open a popup window where you can sign into Gmail and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Gmail API.
Pipedream requests the following authorization scopes when you connect your account:
emailprofileopenidhttps://www.googleapis.com/auth/gmail.labelshttps://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/gmail.composehttps://www.googleapis.com/auth/gmail.settings.basicGEThttps://accounts.google.com/o/oauth2/auth?client_id={{oauth.client_id}}&state={{oauth.state}}&redirect_uri={{oauth.redirect_uri}}&response_type=code&scope={{oauth.space_separated_scopes}}&access_type=offline&prompt=consentPOSThttps://oauth2.googleapis.com/tokencontent-type: application/x-www-form-urlencodedaccept: application/jsonclient_id={{oauth.client_id}}&client_secret={{oauth.client_secret}}&grant_type=authorization_code&code={{oauth.code}}&redirect_uri={{oauth.redirect_uri}}POSThttps://oauth2.googleapis.com/tokencontent-type: application/x-www-form-urlencodedaccept: application/jsonclient_id={{oauth.client_id}}&client_secret={{oauth.client_secret}}&grant_type=refresh_token&refresh_token={{oauth.refresh_token}}