But I got this error: Error
Login Required. DETAILS
Error: Login Required.
at Gaxios._request (/tmp/__pdg__/dist/code/140881d699ead4bfd4256442f2f31c5b9c7dc042d009b4285d5acdce2d9996c9/node_modules/.pnpm/gaxios@6.1.1/node_modules/gaxios/build/src/gaxios.js:141:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.retrieveGoogleTasks (/tmp/__pdg__/dist/code/140881d699ead4bfd4256442f2f31c5b9c7dc042d009b4285d5acdce2d9996c9/code.js:11:22)
at async syncTasks (/tmp/__pdg__/dist/code/140881d699ead4bfd4256442f2f31c5b9c7dc042d009b4285d5acdce2d9996c9/code.js:33:23)
It looks like you’re using process.env.GOOGLE_TOKEN for authentication, which might not be set correctly. In Pipedream, you should use the OAuth access token provided by the Google Tasks app. First, you need to add the Google Tasks app as a prop in your component: props: { google_tasks: { type: "app", app: "google_tasks", }, }, Then, you can use the access token in your API request: ```
const { google } = require(“googleapis”); const { axios } = require(“@pipedream/platform”); export default defineComponent({ props: { google_tasks: { type: “app”, app: “google_tasks”, }, }, async run({ steps, $ }) { const googleTasks = google.tasks({ version: “v1”, auth: this.google_tasks.$auth.oauth_access_token, }); const response = await googleTasks.tasks.list({ tasklist: “Mk1hZng3dVdLeEJ6ZVZqUg”, }); // Your code to sync tasks with Notion }, });
Here’s the updated code using Pipedream component format and including both Google Tasks and Notion integrations: import { google } from "googleapis"; import { NotionClient } from "@notionhq/client"; import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google_tasks: { type: "app", app: "google_tasks", }, notion: { type: "app", app: "notion", }, notion_db_id: { type: "string", label: "Notion Database ID", }, }, async run({ $ }) { const googleTasks = google.tasks({ version: "v1", auth: this.google_tasks.$auth.oauth_access_token, }); const response = await googleTasks.tasks.list({ tasklist: "Mk1hZng3dVdLeEJ6ZVZqUg", }); const googleTasksItems = response.data.items; const notionClient = new NotionClient({ auth: this.notion.$auth.oauth_access_token, }); const notionResponse = await notionClient.databases.query({ database_id: this.notion_db_id, }); const notionPages = notionResponse.results; // logic to match tasks and pages return "Tasks synced!"; }, }); Make sure to replace the tasklist value with your own Google Tasks list ID and provide your Notion Database ID as a prop when using this component.
I’m using the following code, but I would like for the notion account and the google tasks account to both be props in the configuration instead of hard lines in the code. Can you change the code to match that?
Your code already has both the Notion and Google Tasks accounts set up as props in the component configuration. The notion and google_tasks props are correctly defined, and their respective access tokens are being used in the API requests. If you want to remove the hard-coded Google Tasks list ID, you can add a new prop for the tasklist ID: ```
import { google } from “googleapis”; import { NotionClient } from “@notionhq/client”; import { axios } from “@pipedream/platform”; export default defineComponent({ props: { google_tasks: { type: “app”, app: “google_tasks”, }, notion: { type: “app”, app: “notion”, }, notion_db_id: { type: “string”, label: “Notion Database ID”, }, tasklist_id: { type: “string”, label: “Google Tasks List ID”, }, }, async run({ $ }) { const googleTasks = google.tasks({ version: “v1”, auth: this.google_tasks.$auth.oauth_access_token, }); const response = await googleTasks.tasks.list({ tasklist: this.tasklist_id, }); const googleTasksItems = response.data.items; const notionClient = new NotionClient({ auth: this.notion.$auth.oauth_access_token, }); const notionResponse = await notionClient.databases.query({ database_id: this.notion_db_id, }); const notionPages = notionResponse.results; // logic to match tasks and pages return “Tasks synced!”; }, });
I apologize for the inconvenience. It seems like there’s an issue with the authentication for either the Notion or Google Tasks API. To help you further, can you please let me know at which point in the code you’re encountering the “Login Required” error? This will help me identify the issue and provide a solution.
Apologies for the confusion earlier. You’re right, you should use the google_tasks app for authentication. However, the import statement should still be import { google } from "googleapis"; since that’s the correct way to import the Google APIs client library. The google_tasks app is used for authentication, while the google object from googleapis is used to interact with the Google Tasks API. Here’s the corrected code with the proper usage of google_tasks: import { google } from "googleapis"; import { Client as NotionClient } from "@notionhq/client"; export default defineComponent({ props: { google_tasks: { type: "app", app: "google_tasks", }, notion: { type: "app", app: "notion", }, notion_db_id: { type: "string", label: "Notion Database ID", }, tasklist_id: { type: "string", label: "Google Tasks List ID", }, }, async run({ $ }) { const googleTasks = google.tasks({ version: "v1", auth: this.google_tasks.$auth.oauth_access_token, }); const response = await googleTasks.tasks.list({ tasklist: this.tasklist_id, }); const googleTasksItems = response.data.items; const notionClient = new NotionClient({ auth: this.notion.$auth.oauth_access_token, }); const notionResponse = await notionClient.databases.query({ database_id: this.notion_db_id, }); const notionPages = notionResponse.results; // logic to match tasks and pages return "Tasks synced!"; }, }); This should work as expected with the google_tasks app for authentication.
Here’s the error I get when I use that code: Error
Login Required. DETAILS
at Gaxios._request (/tmp/__pdg__/dist/code/cc2ea82d0e067ab502505a0de54c55f6e7fede154fe451be6605bc70a3d44570/node_modules/.pnpm/gaxios@6.1.1/node_modules/gaxios/build/src/gaxios.js:141:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at Object.run (file:///tmp/__pdg__/dist/code/cc2ea82d0e067ab502505a0de54c55f6e7fede154fe451be6605bc70a3d44570/component.mjs:29:22)
at null.executeComponent (/var/task/launch_worker.js:229:22)
at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)
When using that code I got this error: Error
Login Required. DETAILS
at Gaxios._request (/tmp/__pdg__/dist/code/cc2ea82d0e067ab502505a0de54c55f6e7fede154fe451be6605bc70a3d44570/node_modules/.pnpm/gaxios@6.1.1/node_modules/gaxios/build/src/gaxios.js:141:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at Object.run (file:///tmp/__pdg__/dist/code/cc2ea82d0e067ab502505a0de54c55f6e7fede154fe451be6605bc70a3d44570/component.mjs:29:22)
at null.executeComponent (/var/task/launch_worker.js:229:22)
at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)
at Gaxios._request (/tmp/__pdg__/dist/code/cc2ea82d0e067ab502505a0de54c55f6e7fede154fe451be6605bc70a3d44570/node_modules/.pnpm/gaxios@6.1.1/node_modules/gaxios/build/src/gaxios.js:141:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at Object.run (file:///tmp/__pdg__/dist/code/cc2ea82d0e067ab502505a0de54c55f6e7fede154fe451be6605bc70a3d44570/component.mjs:29:22)
at null.executeComponent (/var/task/launch_worker.js:229:22)
at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)
I’m trying to create a workflow that syncs my google tasks to my notion database. I’m stuck on a step to match the google tasks to the notion tasks by matching the google tasks notes to the notion private url. How would you create that step?