Skip to content

Commit 07b88d9

Browse files
committed
add scope as an optional parameter to backendClient
1 parent eb08d0a commit 07b88d9

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

packages/sdk/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
# Changelog
44

5+
## [1.7.0] - 2025-07-03
6+
7+
### Added
8+
9+
- Added optional scope parameter to backendClient creation.
10+
511
## [1.6.11] - 2025-07-02
612

713
### Added

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@pipedream/sdk",
33
"type": "module",
4-
"version": "1.6.11",
4+
"version": "1.7.0",
55
"description": "Pipedream SDK",
66
"main": "./dist/server.js",
77
"module": "./dist/server.js",

packages/sdk/src/server/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export type BackendClientOpts = {
5656
* https://pipedream.com/docs/workflows/domains
5757
*/
5858
workflowDomain?: string;
59+
60+
/**
61+
* OAuth scope to request when obtaining access tokens
62+
*/
63+
scope?: string[];
5964
};
6065

6166
/**
@@ -197,6 +202,7 @@ export class BackendClient extends BaseClient {
197202
};
198203
protected override projectId: string = "";
199204
private staticAccessToken?: string;
205+
private scope?: string[];
200206

201207
/**
202208
* Constructs a new ServerClient instance.
@@ -209,6 +215,7 @@ export class BackendClient extends BaseClient {
209215

210216
this.ensureValidEnvironment(opts.environment);
211217
this.projectId = opts.projectId;
218+
this.scope = opts.scope;
212219
if ("accessToken" in opts.credentials) {
213220
this.staticAccessToken = opts.credentials.accessToken;
214221
} else {
@@ -294,6 +301,11 @@ export class BackendClient extends BaseClient {
294301
}
295302

296303
const parameters = new URLSearchParams();
304+
if (this.scope && this.scope.length > 0) {
305+
parameters.set("scope", this.scope.join(" "));
306+
}
307+
parameters.set("project_id", this.projectId);
308+
parameters.set("environment", this.environment);
297309
try {
298310
const response = await oauth.clientCredentialsGrantRequest(as, client, clientAuth, parameters);
299311
const oauthTokenResponse = await oauth.processClientCredentialsResponse(as, client, response);

pnpm-lock.yaml

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)