Migrating to the 1.0 SDK
💡
This guide is only relevant if:
- You used the
0.x
version of the JavaScript SDK - You authenticated with the Pipedream API using project keys
What changed
- In the
0.x
version of the SDK and the original Connect API, you could authenticate with keys scoped to a specific project. In the1.x
version of the SDK, you need to authenticate with OAuth clients. - The
createClient
method from both the browser and Node.js SDKs has been replaced with separate methods:createFrontendClient
andcreateBackendClient
, respectively. - The
connectTokenCreate
method has been renamedcreateConnectToken
- New SDK methods:
projectInfo
,invokeWorkflow
, and more
How to migrate
Create an OAuth client
Follow the instructions here to create an OAuth client.
Update your SDK version
Change the @pipedream/sdk
version in your package.json
:
{
"dependencies": {
"@pipedream/sdk": "^1.0.0"
}
}
Then run
npm install
Update your project key references to use your OAuth client
You may have been referencing project keys in environment variables or other config. Replace these with references to the OAuth client you created in step 1.
For example, process.env.PIPEDREAM_PROJECT_KEY
should be replaced with process.env.PIPEDREAM_OAUTH_CLIENT_ID
, and process.env.PIPEDREAM_PROJECT_SECRET
should be replaced with process.env.PIPEDREAM_OAUTH_CLIENT_SECRET
.
Update your SDK code
Frontend client
You’ll need to make two changes to your frontend client code:
- Replace references to
@pipedream/sdk/browser
. Instead, import directly from@pipedream/sdk
. - Change the
createClient
method tocreateFrontendClient
.
import { createFrontendClient } from "@pipedream/sdk/browser"
const pd = createFrontendClient()
Backend client
You’ll need to make three changes to your backend code:
- Change the
createClient
method tocreateBackendClient
. - Pass your OAuth client ID and secret to the
createBackendClient
method, removing references to project keys. - Change any token create method references from
connectTokenCreate
tocreateConnectToken
.
import { createBackendClient, HTTPAuthType } from "@pipedream/sdk/server";
// These secrets should be saved securely and passed to your environment
const pd = createBackendClient({
credentials: {
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
},
});