This topic was automatically generated from Slack. You can find the original thread here.
can you help with this?
This topic was automatically generated from Slack. You can find the original thread here.
can you help with this?
Sure, I’d be happy to help! Could you please provide more details about what you need assistance with? For example: - Are you looking for help with a specific Pipedream workflow? - Do you need help integrating with a particular app or API? - Are you encountering an error or issue that you need help troubleshooting? The more details you provide, the better I can assist you.
Hi folks, I’m running in a pretty basic issue when trying to automatically forward emails in gmail including their attachments.
I’ve setup filters in gmail to automatically label incoming invoices, but unfortunately I cannot handle the forwarding in gmail since the recipient is a robot email I cannot confirm it as an authorized forwarding email address.
So I’m trying the following (since there’s no email forwarding action available)
1.
export default defineComponent({
async run({ steps, $ }) {
const emailId = steps.trigger.event.messageId;
const message = await $.google.gmail.users.messages.get({
userId: "me",
id: emailId,
});
const parts = message.payload.parts || [];
const foundAttachments = parts
.filter(part => part.filename && part.body && part.body.attachmentId)
.map(part => ({
filename: part.filename,
attachmentId: part.body.attachmentId,
}));
return { foundAttachments };
},
});
2. const message = await $.service('gmail').getMessage({ id: emailId, userId: 'me' });
Alternatively I could also break it up by attachment do this:
To help you forward emails with attachments from Gmail to your accountant’s robot email, you can use Pipedream to create a workflow with the following steps: 1. Trigger: When a new labeled email is received (label=“Incoming-Invoice”). 2. Code Step: Extract attachments from the email. 3. Action: Send an email with the extracted attachments. 4. (Optional) Action: Add a label to the processed email. Here’s how you can set up each step: ### Step 1: Trigger on New Labeled Email Use the “New Labeled Email” trigger from the Gmail app. ### Step 2: Extract Attachments Create a code step to extract attachments from the email. Here’s the code for this step: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { gmail: { type: "app", app: "gmail", }, }, async run({ steps, $ }) { const emailId = steps.trigger.event.messageId; const message = await axios($, { url: `https://www.googleapis.com/gmail/v1/users/me/messages/${emailId}`, headers: { Authorization: `Bearer ${this.gmail.$auth.oauth_access_token}`, }, }); const parts = message.payload.parts || []; const foundAttachments = parts .filter(part => part.filename && part.body && part.body.attachmentId) .map(part => ({ filename: part.filename, attachmentId: part.body.attachmentId, })); const attachments = await Promise.all(foundAttachments.map(async (attachment) => { const attachmentData = await axios($, { url: `https://www.googleapis.com/gmail/v1/users/me/messages/${emailId}/attachments/${attachment.attachmentId}`, headers: { Authorization: `Bearer ${this.gmail.$auth.oauth_access_token}`, }, }); return { filename: attachment.filename, data: attachmentData.data, }; })); return { attachments }; }, });
### Step 3: Send Email with Attachments Use the “Send Email” action from the Email app to send the extracted attachments. Here’s an example of how you can do this: ``` export default defineComponent({ props: { email: { type: “app”, app: “email”, }, }, async run({ steps
Step 2 above is yielding the following scope error:
AxiosError - Request failed with status code 403
{“error”:{“code”:403,“message”:“Request had insufficient authentication scopes.“,”errors”:[{“message”:“Insufficient Permission”,“domain”:“global”,“reason”:“insufficientPermissions”}],“status”:“PERMISSION_DENIED”,“details”:[{“@type”:“type.googleapis.com/google.rpc.ErrorInfo”,“reason”:“ACCESS_TOKEN_SCOPE_INSUFFICIENT”,“domain”:“googleapis.com”,“metadata”:{“service”:“gmail.googleapis.com”,“method”:“caribou.api.proto.MailboxService.GetMessage”}}]}}
DETAILS
at null.settle (/tmp/__pdg__/dist/code/c1a5f56185183d518777687de9eddce5826b9a3ff69360d22bfa7cf32f53fcfa/node_modules/.pnpm/axios@1.7.2/node_modules/axios/dist/node/axios.cjs:1983:12)
at Unzip.handleStreamEnd (/tmp/__pdg__/dist/code/c1a5f56185183d518777687de9eddce5826b9a3ff69360d22bfa7cf32f53fcfa/node_modules/.pnpm/axios@1.7.2/node_modules/axios/dist/node/axios.cjs:3085:11)
at Unzip.emit (node:events:531:35)
at null.endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at null.callAxios (/tmp/__pdg__/dist/code/c1a5f56185183d518777687de9eddce5826b9a3ff69360d22bfa7cf32f53fcfa/node_modules/.pnpm/@pipedream+platform@3.0.0/node_modules/@pipedream/platform/dist/axios.js:110:26)
at Object.run (file:///tmp/__pdg__/dist/code/c1a5f56185183d518777687de9eddce5826b9a3ff69360d22bfa7cf32f53fcfa/component.mjs:12:21)
at null.executeComponent (/var/task/launch_worker.js:292:22)
at MessagePort.messageHandler (/var/task/launch_worker.js:792:28)
steps.download_all_attachments
{1}
debug
{5}
status:
403
statusText:
Forbidden
headers
{11}
www-authenticate
Bearer realm=”
https://accounts.google.com/
“, error=“insufficient_scope”, scope=”
https://mail.google.com/ https://mail.google.com/mail/feed/atom https://mail.google.com https://mail.google.com/mail/feed/atom/ https://mail.google.com/mail https://mail.google.com/mail/ http://mail.google.com/ http://mail.google.com https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.metadata https://www.googleapis.com/auth/gmail.addons.current.message.metadata https://www.googleapis.com/auth/gmail.addons.current.message.readonly https://www.googleapis.com/auth/gmail.addons.current.message.action”
vary:
Origin, X-Origin, Referer
content-type:
application/json; charset=UTF-8
date:
Mon, 22 Jul 2024 07:31:17 GMT
server:
ESF
cache-control:
private
x-xss-protection:
0
x-frame-options:
SAMEORIGIN
x-content-type-options:
nosniff
alt-svc:
h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
transfer-encoding:
chunked
config
{13}
transitional
{3}
adapter
[3]
transformRequest
[1]
transformResponse
[1]
timeout:
0
xsrfCookieName:
XSRF-TOKEN
xsrfHeaderName:
X-XSRF-TOKEN
maxContentLength:
-1
maxBodyLength:
-1
env
{0}
-more-
data
{1}
Test
You should visit Pricing - Pipedream for the latest pricing, but I’ll do my best to answer. The error you’re encountering indicates that the access token used in your request does not have the necessary scopes to perform the action. Specifically, the error message mentions “insufficient_scope” and lists the required scopes. To resolve this issue, you need to ensure that your OAuth token has the necessary scopes. For Gmail, the relevant scopes might include: - https://mail.google.com/
- https://www.googleapis.com/auth/gmail.modify
- https://www.googleapis.com/auth/gmail.readonly
- https://www.googleapis.com/auth/gmail.metadata
- https://www.googleapis.com/auth/gmail.addons.current.message.metadata
- https://www.googleapis.com/auth/gmail.addons.current.message.readonly
- https://www.googleapis.com/auth/gmail.addons.current.message.action
Here’s what you can do: 1. Check OAuth Scopes: Ensure that when you authorize your Gmail app in Pipedream, you request the necessary scopes. You can do this by reauthorizing the app with the correct scopes. 2. Update Your Component: Make sure your Pipedream component includes the necessary scopes. Here’s an example of how to set up a Pipedream component with the required Gmail scopes: ```
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/gmail/v1/users/me/messages
, headers: { Authorization: Bearer ${this.gmail.$auth.oauth_access_token}
, }, }); }, });
but why is it asking me to authenticate/configure a gmail account at step 2 since my trigger already is connected to my gmail account?
It seems like you’re encountering an issue where Pipedream is asking you to authenticate or configure a Gmail account at step 2, even though your trigger is already connected to your Gmail account. This can happen because each step in a Pipedream workflow that interacts with an external service needs to have the appropriate credentials configured. Here’s a detailed explanation: 1. Trigger Authentication: When you set up a trigger that connects to Gmail, you authenticate your Gmail account for that specific trigger. This allows Pipedream to listen for events from your Gmail account. 2. Action Authentication: When you add an action step that also interacts with Gmail, Pipedream requires you to authenticate your Gmail account for that action step as well. This is because each step operates independently and needs to have the necessary credentials to perform its actions. ### How to Authenticate Your Gmail Account for the Action Step 1. Search for the Gmail app from the step menu. 2. Select the desired action (e.g., Send Email). 3. Connect your Gmail account: You will be prompted to authenticate your Gmail account. If you’ve already connected your Gmail account, you should see it listed as an option to select. 4. Configure the action: Fill in the required fields (e.g., To, Subject, Email Body). 5. Test the action: Click Test to run the action and ensure it is configured correctly. ### Example of Connecting a Gmail Account in a Pipedream Component Here’s an example of how you might set up a Pipedream component that connects to Gmail: 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}`, }, }); }, });
In this example, the props
object includes a gmail
property that allows you to connect your Gmail account. The run
method then makes an authenticated request to the Gmail API using the OAuth access token. ### Additional Resources For more information on connecting accounts and configuring steps, you can refer to the following documentation: - [Connected Accounts](https://piped
Ok, but still, for some reason the authentication at step 2 seems to be faulty. I keep running into the same scope error as before despite having never encountered it prior and having marked the pipedream apps as trusted in my google workspace…
Error:
AxiosError - Request failed with status code 403
{“error”:{“code”:403,“message”:“Request had insufficient authentication scopes.“,”errors”:[{“message”:“Insufficient Permission”,“domain”:“global”,“reason”:“insufficientPermissions”}],“status”:“PERMISSION_DENIED”,“details”:[{“@type”:“type.googleapis.com/google.rpc.ErrorInfo”,“reason”:“ACCESS_TOKEN_SCOPE_INSUFFICIENT”,“domain”:“googleapis.com”,“metadata”:{“method”:“caribou.api.proto.MailboxService.ListMessages”,“service”:“gmail.googleapis.com”}}]}}
DETAILS
at null.settle (/tmp/__pdg__/dist/code/5666203a800618552609c3299ee9047894e8fa91b8c496b4e66a0bec31af0511/node_modules/.pnpm/axios@1.7.2/node_modules/axios/dist/node/axios.cjs:1983:12)
at Unzip.handleStreamEnd (/tmp/__pdg__/dist/code/5666203a800618552609c3299ee9047894e8fa91b8c496b4e66a0bec31af0511/node_modules/.pnpm/axios@1.7.2/node_modules/axios/dist/node/axios.cjs:3085:11)
at Unzip.emit (node:events:531:35)
at null.endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at null.callAxios (/tmp/__pdg__/dist/code/5666203a800618552609c3299ee9047894e8fa91b8c496b4e66a0bec31af0511/node_modules/.pnpm/@pipedream+platform@3.0.0/node_modules/@pipedream/platform/dist/axios.js:110:26)
at Object.run (file:///tmp/__pdg__/dist/code/5666203a800618552609c3299ee9047894e8fa91b8c496b4e66a0bec31af0511/component.mjs:11:12)
at null.executeComponent (/var/task/launch_worker.js:292:22)
at MessagePort.messageHandler (/var/task/launch_worker.js:792:28)
steps.download_all_attachments
{1}
debug
{5}
Test
Continue
JOBA**LTO AUTOMATIONS**
G-SU**ITE**
EDIT
Exit to project
Copy of Batchrun Salaires Zip folder to GDrive
Draft
6 issues
Deploy