Gmail offers private and secure email by Google at no cost, for business and consumer accounts.
Go to siteBy 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 APIs & Services
Click Enable APIs & Services
Search for and select Gmail API
Click Enable
Search for and select Cloud Pub/Sub API
Click Enable
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
Set up the OAuth consent screen:
email
, profile
, https://www.googleapis.com/auth/gmail.modify
, https://www.googleapis.com/auth/gmail.settings.basic
Navigate to the Credentials section on the left side.
Click Create Credentials at the top and select OAuth client ID
Select Web application for Application type
Name the app, e.g. "Pipedream".
In a new window, navigate to the Accounts page in Pipedream, and click OAuth Clients.
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.
Click Create to create your new OAuth keys.
Copy the Client ID and Client Secret, and paste them in your OAuth Client configuration 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.
Add a name and description for your service account, and grant the service account the role Pub/Sub Admin, and click Done.
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.
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.
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)
Create a draft from your Google Workspace email account. See the documentation
Download an attachment by attachmentId to the /tmp directory. 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:
email
profile
openid
https://www.googleapis.com/auth/gmail.labels
https://www.googleapis.com/auth/gmail.send
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.compose
https://www.googleapis.com/auth/gmail.settings.basic
GET
https://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=consent
POST
https://oauth2.googleapis.com/token
content-type: application/x-www-form-urlencoded
accept: application/json
client_id={{oauth.client_id}}
&
client_secret={{oauth.client_secret}}
&
grant_type=authorization_code
&
code={{oauth.code}}
&
redirect_uri={{oauth.redirect_uri}}
POST
https://oauth2.googleapis.com/token
content-type: application/x-www-form-urlencoded
accept: application/json
client_id={{oauth.client_id}}
&
client_secret={{oauth.client_secret}}
&
grant_type=refresh_token
&
refresh_token={{oauth.refresh_token}}