Hi Mitch, thanks for the detailed bug report, we don’t recommend attempting to perform OAuth in code steps. Instead, you can add an app prop to your code step to connect your accounts.
Then Pipedream handles the OAuth handshake and refresh tokens for you.
I apologize for the confusion earlier. It seems we currently do not have a Canva integration available on Pipedream. In this case, you can submit an integration request for Canva at this link: New Pipedream Integration Request Once the Canva integration is available, you’ll be able to use it in a Node.js code step to make authenticated API requests.
ok, I will request this, and also, I’m needing a fix asap, and the cookie issue is the blocker, the rest is in place.
Is there a way to go about setting a cookie as part of a response to a request that will be saved in the browser and available when the user is immediately redirected back to the same endpoint with different path?
No, sorry, like I mentioned before, we do not support OAuth in code steps like the way you’re attempting.
The Pipedream backend will handle the OAuth flow, and then expose the Canva API token through the app prop. That will produce a Canva API key for your account to use in Node.js code steps. Not cookies. Cookies are for frontend sessions only.
can you show me how to use an app prop to send an authenticated API in a Node.js code step?
I apologize for the confusion earlier, as we currently do not have a Canva integration available on Pipedream. However, I can show you a general example of how to use an app prop to send an authenticated API request in a Node.js code step. Let’s assume we have an app called exampleApp: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { exampleApp: { type: "app", app: "exampleApp", }, }, async run({ steps, $ }) { const apiUrl = "https://api.example.com/some/endpoint"; const accessToken = this.exampleApp.$auth.oauth_access_token; const response = await axios($, { method: "GET", url: apiUrl, headers: { Authorization: `Bearer ${accessToken}`, }, }); return response; }, }); In this example, we’re using an app prop called exampleApp to connect to the app. The access token is available at this.exampleApp.$auth.oauth_access_token. We then use the axios constructor from the @pipedream/platform package to make an authenticated API request. Please note that this is just a general example. Once the Canva integration is available, you’ll be able to replace exampleApp with the appropriate Canva app prop.
Thanks for the screenshot, but once again the Pipedream backend will take care of that implementation for you. Then you can use the Node.js code shown by Pi to send an authenticated request.
We do not support performing OAuth handshakes within Node.js code steps directly.
Canva doesn’t authenticate users by cookies, instead they’ll issue a JWT:
When this integration is live, then you’ll be able to connect your Canva account to Pipedream just like any other app integration. I recommend trying the Google Sheets or Slack apps as an example.
After you connect your Canva account, then you’ll be able to leverage this JWT from your Canva account with the Canva API.