Skip to content

Commit e8773e7

Browse files
committed
Apply PR feedback
1 parent e1e7efc commit e8773e7

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

packages/sdk/src/server/index.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ export type CreateServerClientOpts = {
3030
/**
3131
* The client ID of your workspace's OAuth application.
3232
*/
33-
oauthClientId: string;
33+
oauthClientId?: string;
3434

3535
/**
3636
* The client secret of your workspace's OAuth application.
3737
*/
38-
oauthClientSecret: string;
38+
oauthClientSecret?: string;
3939

4040
/**
4141
* The API host URL. Used by Pipedream employees. Defaults to "api.pipedream.com" if not provided.
@@ -246,7 +246,7 @@ export type ErrorResponse = {
246246
export type ConnectAPIResponse<T> = T | ErrorResponse;
247247

248248
/**
249-
* Options for making a request to the Connect API.
249+
* Options for making a request to the Pipedream API.
250250
*/
251251
interface RequestOptions extends Omit<RequestInit, "headers"> {
252252
/**
@@ -301,13 +301,27 @@ class ServerClient {
301301
const { apiHost = "api.pipedream.com" } = opts;
302302
this.baseURL = `https://${apiHost}/v1`;
303303

304+
this._configureOauthClient(opts, this.baseURL);
305+
}
306+
307+
private _configureOauthClient(
308+
{
309+
oauthClientId: id,
310+
oauthClientSecret: secret,
311+
}: CreateServerClientOpts,
312+
tokenHost: string,
313+
) {
314+
if (!id || !secret) {
315+
return;
316+
}
317+
304318
this.oauthClient = new ClientCredentials({
305319
client: {
306-
id: opts.oauthClientId,
307-
secret: opts.oauthClientSecret,
320+
id,
321+
secret,
308322
},
309323
auth: {
310-
tokenHost: this.baseURL,
324+
tokenHost,
311325
tokenPath: "/v1/oauth/token",
312326
},
313327
});
@@ -395,7 +409,7 @@ class ServerClient {
395409
}
396410

397411
/**
398-
* Makes a request to the Connect API.
412+
* Makes a request to the Pipedream API.
399413
*
400414
* @template T - The expected response type.
401415
* @param path - The API endpoint path.

0 commit comments

Comments
 (0)