Skip to content

Commit 38d537b

Browse files
authored
(feat) Removing appSlug and oauthClientId from token create call (#14123)
1 parent 4e561f0 commit 38d537b

File tree

4 files changed

+104
-102
lines changed

4 files changed

+104
-102
lines changed

docs-v2/pages/connect/api.mdx

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ import { createClient } from "@pipedream/sdk/browser"
7777
import { serverConnectTokenCreate } from "./server"
7878

7979
const { token, expires_at } = await serverConnectTokenCreate({
80-
app_slug: appSlug, // The app's name slug — see the quickstart
81-
oauth_app_id: oauthAppId, // The OAuth app ID, if you're connecting an OAuth app — keep this in config / a DB, pass here
82-
external_id: externalUserId // The end user's ID in your system
80+
external_user_id: externalUserId // The end user's ID in your system
8381
});
8482

8583
export default function Home() {
@@ -148,9 +146,9 @@ POST /tokens
148146

149147
##### Parameters
150148

151-
- `app_slug` - [The app's name slug](/quickstart#find-your-apps-name-slug)
152-
- `oauth_app_id` - [The OAuth app ID](/quickstart#creating-a-custom-oauth-client), if you're connecting an OAuth app — keep this in config / a DB, pass here
153149
- `external_id` - [The external user ID](#external-users) in your system
150+
- `success_redirect_uri`_Optional_. The URL to redirect the user to after they successfully connect an account
151+
- `error_redirect_uri`_Optional_. The URL to redirect the user to if they encounter an error during the connection flow
154152

155153
##### Examples
156154

@@ -180,9 +178,7 @@ export async function serverConnectTokenCreate(opts: ConnectTokenCreateOpts): Pr
180178
}
181179

182180
const { token, expires_at } = await serverConnectTokenCreate({
183-
app_slug: appSlug, // The app's name slug
184-
oauth_app_id: oauthAppId, // The OAuth app ID, if you're connecting an OAuth app — keep this in config / a DB, pass here
185-
external_id: externalUserId // The end user's ID in your system
181+
external_user_id: externalUserId // The end user's ID in your system
186182
});
187183
```
188184
</Tabs.Tab>
@@ -225,8 +221,6 @@ const client = new Client({
225221
});
226222

227223
const connectTokenOpts = {
228-
app_slug: "YOUR_APP_SLUG", // The app's name slug
229-
oauth_app_id: "o_abc123", // The OAuth app ID, if you're connecting an OAuth app — keep this in config / a DB, pass here
230224
external_id: "USER_ID" // The end user's ID in your system
231225
}
232226

@@ -272,14 +266,12 @@ class Client:
272266

273267
# Usage example
274268
client = Client({
275-
'public_key': 'YOUR_PUBLIC_KEY',
276-
'secret_key': 'YOUR_SECRET_KEY',
269+
'public_key': 'YOUR_PUBLIC_KEY',
270+
'secret_key': 'YOUR_SECRET_KEY',
277271
})
278272

279273
connect_token_opts = {
280-
'app_slug': "YOUR_APP_SLUG",
281-
'oauth_app_id': "o_abc123",
282-
'external_id': "USER_ID"
274+
'external_id': "USER_ID"
283275
}
284276

285277
# Expose this code as an API endpoint in your server to fetch the token from the frontend
@@ -313,7 +305,7 @@ public class Client {
313305
return "Basic " + encoded;
314306
}
315307

316-
public String connectTokenCreate(String appSlug, String oauthClientId, String externalId) throws Exception {
308+
public String connectTokenCreate(String externalId) throws Exception {
317309
String auth = authorizationHeader();
318310
URL url = new URL(baseURL + "/v1/connect/tokens");
319311
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
@@ -322,7 +314,7 @@ public class Client {
322314
conn.setRequestProperty("Content-Type", "application/json");
323315
conn.setDoOutput(true);
324316

325-
String jsonInputString = String.format("{\"app_slug\":\"%s\",\"oauth_app_id\":\"%s\",\"external_id\":\"%s\"}", appSlug, oauthClientId, externalId);
317+
String jsonInputString = String.format("{\"external_id\":\"%s\"}", externalId);
326318

327319
try (OutputStream os = conn.getOutputStream()) {
328320
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
@@ -336,7 +328,7 @@ public class Client {
336328
Client client = new Client("YOUR_SECRET_KEY", "YOUR_PUBLIC_KEY");
337329

338330
// Expose this code as an API endpoint in your server to fetch the token from the frontend
339-
String response = client.connectTokenCreate("YOUR_APP_SLUG", "o_abc123", "USER_ID");
331+
String response = client.connectTokenCreate("USER_ID");
340332
}
341333
}
342334

@@ -367,13 +359,13 @@ public class Client {
367359
return $"Basic {encoded}";
368360
}
369361

370-
public async Task<string> ConnectTokenCreate(string appSlug, string oauthClientId, string externalId) {
362+
public async Task<string> ConnectTokenCreate(string externalId) {
371363
string auth = AuthorizationHeader();
372364
using (HttpClient client = new HttpClient()) {
373365
client.DefaultRequestHeaders.Add("Authorization", auth);
374366
client.DefaultRequestHeaders.Add("Content-Type", "application/json");
375367

376-
var content = new StringContent($"{{\"app_slug\":\"{appSlug}\",\"oauth_app_id\":\"{oauthClientId}\",\"external_id\":\"{externalId}\"}}", Encoding.UTF8, "application/json");
368+
var content = new StringContent($"{{\"external_id\":\"{externalId}\"}}", Encoding.UTF8, "application/json");
377369
var response = await client.PostAsync($"{baseURL}/v1/connect/tokens", content);
378370

379371
return await response.Content.ReadAsStringAsync();
@@ -384,7 +376,7 @@ public class Client {
384376
var client = new Client("YOUR_SECRET_KEY", "YOUR_PUBLIC_KEY");
385377

386378
// Expose this code as an API endpoint in your server to fetch the token from the frontend
387-
string response = await client.ConnectTokenCreate("YOUR_APP_SLUG", "o_abc123", "USER_ID");
379+
string response = await client.ConnectTokenCreate("USER_ID");
388380
}
389381
}
390382

@@ -424,13 +416,11 @@ func (c *Client) authorizationHeader() string {
424416
return fmt.Sprintf("Basic %s", encoded)
425417
}
426418

427-
func (c *Client) ConnectTokenCreate(appSlug, oauthClientId, externalId string) (map[string]interface{}, error) {
419+
func (c *Client) ConnectTokenCreate(externalId string) (map[string]interface{}, error) {
428420
auth := c.authorizationHeader()
429421
url := fmt.Sprintf("%s/v1/connect/tokens", c.BaseURL)
430422

431423
opts := map[string]string{
432-
"app_slug": appSlug,
433-
"oauth_app_id": oauthClientId,
434424
"external_id": externalId,
435425
}
436426

@@ -465,7 +455,7 @@ func main() {
465455
client := NewClient("YOUR_SECRET_KEY", "YOUR_PUBLIC_KEY")
466456

467457
// Expose this code as an API endpoint in your server to fetch the token from the frontend
468-
response, err := client.ConnectTokenCreate("YOUR_APP_SLUG", "o_abc123", "USER_ID")
458+
response, err := client.ConnectTokenCreate( "USER_ID")
469459
if err != nil {
470460
fmt.Println("Error:", err)
471461
return
@@ -496,13 +486,11 @@ class Client {
496486
return "Basic $encoded";
497487
}
498488

499-
public function connectTokenCreate($appSlug, $oauthClientId, $externalId) {
489+
public function connectTokenCreate($externalId) {
500490
$auth = $this->authorizationHeader();
501491
$url = "$this->baseURL/v1/connect/tokens";
502492

503493
$data = json_encode([
504-
'app_slug' => $appSlug,
505-
'oauth_app_id' => $oauthClientId,
506494
'external_id' => $externalId
507495
]);
508496

@@ -528,13 +516,11 @@ class Client {
528516
$client = new Client('YOUR_SECRET_KEY', 'YOUR_PUBLIC_KEY');
529517

530518
$connectTokenOpts = [
531-
'app_slug' => "YOUR_APP_SLUG",
532-
'oauth_app_id' => "o_abc123",
533519
'external_id' => "USER_ID"
534520
];
535521

536522
// Expose this code as an API endpoint in your server to fetch the token from the frontend
537-
$response = $client->connectTokenCreate($connectTokenOpts['app_slug'], $connectTokenOpts['oauth_app_id'], $connectTokenOpts['external_id']);
523+
$response = $client->connectTokenCreate($connectTokenOpts['external_id']);
538524
?>
539525
```
540526
</Tabs.Tab>
@@ -564,7 +550,7 @@ class Client
564550
req = Net::HTTP::Post.new(uri)
565551
req['Authorization'] = authorization_header
566552
req['Content-Type'] = 'application/json'
567-
req.body = { app_slug: app_slug, oauth_app_id: oauth_app_id, external_id: external_id }.to_json
553+
req.body = { external_id: external_id }.to_json
568554

569555
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
570556
http.request(req)
@@ -577,13 +563,11 @@ end
577563
client = Client.new('YOUR_SECRET_KEY', 'YOUR_PUBLIC_KEY')
578564

579565
connect_token_opts = {
580-
app_slug: "YOUR_APP_SLUG",
581-
oauth_app_id: "o_abc123",
582566
external_id: "USER_ID"
583567
}
584568

585569
# Expose this code as an API endpoint in your server to fetch the token from the frontend
586-
response = client.connect_token_create(connect_token_opts[:app_slug], connect_token_opts[:oauth_app_id], connect_token_opts[:external_id])
570+
response = client.connect_token_create(connect_token_opts[:external_id])
587571
```
588572
</Tabs.Tab>
589573
</Tabs>

0 commit comments

Comments
 (0)