Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fixes for Arcade 1.0.0 #94

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=
Comment on lines +101 to +102
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this, I was able to post to LinkedIn as an org. Without LINKEDIN_ORGANIZATION_ID, the agent logged an error about this var being missing.

```

### Install LangGraph CLI

```bash
Expand Down Expand Up @@ -217,6 +226,15 @@ Create an Arcade account [here](https://www.arcade.dev). After you register, [ge

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
16 changes: 7 additions & 9 deletions src/agents/shared/auth/linkedin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,13 @@ 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,
}
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same outcome, simpler method 👍

const authUrl = authResponse.url;

if (authUrl) {
Expand Down
32 changes: 14 additions & 18 deletions src/clients/linkedin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,13 @@ 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") {
if (!authRes.context?.token) {
Expand Down Expand Up @@ -324,15 +322,13 @@ 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) {
throw new Error(
Expand Down
16 changes: 7 additions & 9 deletions src/clients/twitter/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,13 @@ 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") {
if (!authRes.context?.token) {
Expand Down
Loading