Skip to content

Commit

Permalink
Merge pull request #94 from nbarbettini/nb-fix-arcade-pt2
Browse files Browse the repository at this point in the history
More fixes for Arcade 1.0.0
  • Loading branch information
bracesproul authored Jan 31, 2025
2 parents 930c216 + 67e3096 commit 5ef5fc8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 32 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ FIRECRAWL_API_KEY=
ARCADE_API_KEY=
```

If you plan to post to LinkedIn as an organization (rather than as yourself), you'll also need to set:

```bash
# Get the organization ID from the URL of the company page when you're logged in as an admin.
# For example, if the URL is `https://www.linkedin.com/company/12345678/admin/dashboard/`, the organization ID would be `12345678`.
POST_TO_LINKEDIN_ORGANIZATION=true
LINKEDIN_ORGANIZATION_ID=
```

### Install LangGraph CLI

```bash
Expand Down Expand Up @@ -217,6 +226,15 @@ Then, you will need to set these environment variables in your `.env` file:

Make sure you have the `USE_ARCADE_AUTH` environment variable set to `true` to have the graph use Arcade authentication.

If you plan to post to LinkedIn as an organization (rather than as yourself), you'll also need to set:

```bash
# Get the organization ID from the URL of the company page when you're logged in as an admin.
# For example, if the URL is `https://www.linkedin.com/company/12345678/admin/dashboard/`, the organization ID would be `12345678`.
LINKEDIN_ORGANIZATION_ID=
POST_TO_LINKEDIN_ORGANIZATION=true
```

> Note:
>
> If you want to upload media to Twitter, you will still need to set up your own Twitter developer account (below) in addition to using Arcade.
Expand Down
10 changes: 2 additions & 8 deletions src/agents/shared/auth/linkedin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,8 @@ async function getArcadeLinkedInAuthOrInterrupt(
const scopes = fields?.postToOrg
? ["w_member_social", "w_organization_social"]
: ["w_member_social"];
const authResponse = await arcade.auth.authorize({
user_id: linkedInUserId,
auth_requirement: {
provider_id: "linkedin",
oauth2: {
scopes,
},
},
const authResponse = await arcade.auth.start(linkedInUserId, "linkedin", {
scopes,
});
const authUrl = authResponse.url;

Expand Down
20 changes: 4 additions & 16 deletions src/clients/linkedin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,8 @@ export class LinkedInClient {
},
): Promise<AuthorizeUserResponse> {
const scopes = LinkedInClient.getScopes(fields?.postToOrganization);
const authRes = await client.auth.authorize({
user_id: id,
auth_requirement: {
provider_id: "linkedin",
oauth2: {
scopes,
},
},
const authRes = await client.auth.start(id, "linkedin", {
scopes,
});

if (authRes.status === "completed") {
Expand Down Expand Up @@ -324,14 +318,8 @@ export class LinkedInClient {
apiKey: process.env.ARCADE_API_KEY,
});
const scopes = LinkedInClient.getScopes(fields?.postToOrganization);
const authRes = await arcade.auth.authorize({
user_id: linkedInUserId,
auth_requirement: {
provider_id: "linkedin",
oauth2: {
scopes,
},
},
const authRes = await arcade.auth.start(linkedInUserId, "linkedin", {
scopes,
});

if (!authRes.context?.token || !authRes.context?.user_info?.sub) {
Expand Down
10 changes: 2 additions & 8 deletions src/clients/twitter/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,8 @@ export class TwitterClient {
id: string,
client: Arcade,
): Promise<AuthorizeUserResponse> {
const authRes = await client.auth.authorize({
user_id: id,
auth_requirement: {
provider_id: "x",
oauth2: {
scopes: ["tweet.write", "users.read", "tweet.read", "offline.access"],
},
},
const authRes = await client.auth.start(id, "x", {
scopes: ["tweet.write", "users.read", "tweet.read", "offline.access"],
});

if (authRes.status === "completed") {
Expand Down

0 comments on commit 5ef5fc8

Please sign in to comment.