Why am I receiving a 404 error when attempting to use Pipedream Connect for the first time in my NextJS application?

This topic was automatically generated from Slack. You can find the original thread here.

Hello, I’m new to Pipedream and attempting to use Pipedream Connect for the first time by following the tutorial. I’ve copied the code into my own NextJS application and am invoking the connectTokenCreate function using a server action from my frontend code (shown in screenshots). I’ve confirmed that my environment variables are correct and that the code is being executed on the server, but I am getting an error when the connectTokenCreate function runs:

Error: HTTP error! status: 404
    at Generator.next (<anonymous>)
digest: "1690150757"

First screenshot is my frontend code, second screenshot is my backend code (where the error occurs). Does anyone have suggestions or am I missing something obvious? Thank you in advance!

in your server component, in the serverConnectTokenCreate function, could you do me a favor and add console.log(opts) at the top of the function and try running it again? Feel free to obfuscate the external_id — I’d like to see the app_slug specifically at that point of the code

that’ll also just make sure data.user.id is set when passed in opts

I’ve doubled checked that data.user.id is set as well, but just hardcoded it for that screenshot

ah got it, we’ll surface this error better, but since Slack is an OAuth app, you’ll need to:

  1. Bring your own Slack OAuth client,
  2. Add that client to Pipedream
  3. Set NEXT_PUBLIC_PIPEDREAM_APP_ID to your OAuth app ID in the token creation process, and pass oauth_app_id in the token creation request
    So that tells Pipedream that you want to use Slack (via app_slug), then specifies the OAuth client that you’ll be using (via oauth_app_id). Does that help?

Oh I see, that makes sense. Thank you for the quick replies and helpful explanation!

Are there apps that would only work with the slug, and no oauth client needed?

yes, any apps that just require API keys for auth requires just the app_slug, like openai for example.

You can tell what auth type is required by the app by visiting Integrated APIs & Applications - Pipedream, search for the app you want to integrate, and visit the Authentication section near the bottom. e.g. for OpenAI (ChatGPT) API Integrations - Pipedream you’ll see the name slug for OpenAI is openai, and that app requires only API keys to use, so you don’t need to create your own client.

Okay great, thanks again!

We’re also working on a way to test with the Pipedream OAuth clients when you’re developing like this. So then you can get the app working end to end with Slack and only have to create your own OAuth client when you ship to prod.

Essentially, we can’t federate access to our OAuth apps for certain apps (like Slack) because of contractual / security restrictions with some partners. But since we know who you (the developer) is and you already have a Pipedream account, totally fine for you to use in development!

sounds like that model would have helped you here

anyway we’ll let you know when that’s out, and please let us know if you hit any other blockers / what’s not working for you! This is exactly the feedback we’re looking for

Oh yeah that does sound useful - would love to know when thats out

Caleb, were you able to get this working either with your own custom OAuth client or with a key-based app like openai?

Hey Danny, apologies for the late reply, I got a bit side tracked with some other work. I am still attempting to get it to work with an oauth app (slack). I’ve confirmed that I am getting the token from pipedream and over to my frontend, but am running into problems when trying to do pd.connectAccount - the UI doesnt load and I get a 404. I’ve attached a screenshot of my updated code and the error.

I can confirm I have connected my slack oauth app with pipedream using the client id and secret, then stored that pipedream app id in my env file. I’ve also installed the slack oauth app to my workspace and given it a scope. I am then able to get the token and create the client, but something goes wrong after that.

you can remove the frontendHost and just instantiate the client with:

const pd = createClient({})

I’ll make that more clear in the docs, but that’s actually for Pipedream devs when we develop against a dev host, but leaving it blank will correctly load the iframe from pipedream.com

Ah that makes sense, that pops up the IFrame! Thanks for the help, just looking at where to verify my domain on Pipedream now

And you should be able to run the example app locally without verifying your domain. But once you’re ready to actually deploy your code, then yes you’ll need to verify your domain: Sign Up - Pipedream