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

feat: Linkedin tool Oauth App #1454

Merged
merged 7 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions apiclient/types/oauthapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
OAuthAppTypeGoogle OAuthAppType = "google"
OAuthAppTypeSalesforce OAuthAppType = "salesforce"
OAuthAppTypeZoom OAuthAppType = "zoom"
OAuthAppTypeLinkedIn OAuthAppType = "linkedin"
OAuthAppTypeCustom OAuthAppType = "custom"
)

Expand Down
6 changes: 6 additions & 0 deletions pkg/gateway/types/oauth_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const (

ZoomAuthorizeURL = "https://zoom.us/oauth/authorize"
ZoomTokenURL = "https://zoom.us/oauth/token"

LinkedInAuthorizeURL = "https://www.linkedin.com/oauth/v2/authorization"
LinkedInTokenURL = "https://www.linkedin.com/oauth/v2/accessToken"
)

var (
Expand Down Expand Up @@ -75,6 +78,9 @@ func ValidateAndSetDefaultsOAuthAppManifest(r *types.OAuthAppManifest, create bo
case types.OAuthAppTypeZoom:
r.AuthURL = ZoomAuthorizeURL
r.TokenURL = ZoomTokenURL
case types.OAuthAppTypeLinkedIn:
r.AuthURL = LinkedInAuthorizeURL
r.TokenURL = LinkedInTokenURL
case types.OAuthAppTypeSalesforce:
salesforceAuthorizeFragment := "/services/oauth2/authorize"
salesforceTokenFragment := "/services/oauth2/token"
Expand Down
2 changes: 2 additions & 0 deletions ui/admin/app/components/oauth-apps/OAuthAppTypeIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
FaAtlassian,
FaGithub,
FaGoogle,
FaLinkedin,
FaMicrosoft,
FaSalesforce,
FaSlack,
Expand All @@ -22,6 +23,7 @@ const IconMap = {
[OAuthProvider.Microsoft365]: FaMicrosoft,
[OAuthProvider.Notion]: NotionLogoIcon,
[OAuthProvider.Zoom]: BiLogoZoom,
[OAuthProvider.LinkedIn]: FaLinkedin,
[OAuthProvider.Custom]: KeyIcon,
};

Expand Down
2 changes: 2 additions & 0 deletions ui/admin/app/lib/model/oauthApps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { AtlassianOAuthApp } from "~/lib/model/oauthApps/providers/atlassian";
import { GitHubOAuthApp } from "~/lib/model/oauthApps/providers/github";
import { GoogleOAuthApp } from "~/lib/model/oauthApps/providers/google";
import { LinkedInOAuthApp } from "~/lib/model/oauthApps/providers/linkedin";
import { Microsoft365OAuthApp } from "~/lib/model/oauthApps/providers/microsoft365";
import { NotionOAuthApp } from "~/lib/model/oauthApps/providers/notion";
import { SalesforceOAuthApp } from "~/lib/model/oauthApps/providers/salesforce";
Expand All @@ -23,6 +24,7 @@ export const OAuthAppSpecMap = {
[OAuthProvider.Salesforce]: SalesforceOAuthApp,
[OAuthProvider.Notion]: NotionOAuthApp,
[OAuthProvider.Zoom]: ZoomOAuthApp,
[OAuthProvider.LinkedIn]: LinkedInOAuthApp,
// Custom OAuth apps are intentionally omitted from the map.
// They are handled separately
} as const;
Expand Down
1 change: 1 addition & 0 deletions ui/admin/app/lib/model/oauthApps/oauth-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const OAuthProvider = {
Salesforce: "salesforce",
Notion: "notion",
Zoom: "zoom",
LinkedIn: "linkedin",
Custom: "custom",
} as const;
export type OAuthProvider = (typeof OAuthProvider)[keyof typeof OAuthProvider];
Expand Down
63 changes: 63 additions & 0 deletions ui/admin/app/lib/model/oauthApps/providers/linkedin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { z } from "zod";

import {
OAuthAppSpec,
OAuthFormStep,
getOAuthLinks,
} from "~/lib/model/oauthApps/oauth-helpers";
import { assetUrl } from "~/lib/utils";

const schema = z.object({
clientID: z.string().min(1, "Client ID is required"),
clientSecret: z.string().min(1, "Client Secret is required"),
});

const steps: OAuthFormStep<z.infer<typeof schema>>[] = [
{
type: "markdown",
text:
"### Step 1: Create a new app in LinkedIn Developer Portal\n" +
"If you already have an app, you can skip to Step 2.\n\n" +
"- Ensure you are logged in to your preferred LinkedIn account.\n" +
"- From the [LinkedIn Developer Portal](https://developer.linkedin.com), click on **Create app**.\n" +
"- Input required fields: *App Name* and *LinkedIn Page*, and upload an app logo, check the legal agreement box and click on **Create App**.\n" +
"- Now you should be redirected to the app's settings page.\n",
},
{
type: "markdown",
text:
"### Step 2: Configure the app\n" +
"- From the [LinkedIn Developer Portal](https://developer.linkedin.com), click **My Apps** and then select the app you'd like to proceed with.\n" +
"(You will already be on this page if you've completed step 1)\n" +
"- Select the **Products** tab and request access for **Share on LinkedIn** and **Sign In with LinkedIn using OpenID Connect**.\n" +
"- Then select the **Auth** tab. In the **OAuth 2.0 settings** section, click on the pencil icon to set the following as redirect URL:\n",
},
{
type: "copy",
text: getOAuthLinks("linkedin").redirectURL,
},
{
type: "markdown",
text:
"### Step 3: Register your App with Obot\n" +
"- **Client ID** and **Client Secret** can be found in the **Application credentials** box, located at the top of the **Auth** tab page.\n" +
"- Copy the **Client ID** and **Client Secret** and paste them into the respective fields below.\n",
},
{ type: "input", input: "clientID", label: "Client ID" },
{
type: "input",
input: "clientSecret",
label: "Client Secret",
inputType: "password",
},
];

export const LinkedInOAuthApp = {
schema,
alias: "linkedin",
type: "linkedin",
displayName: "LinkedIn",
logo: assetUrl("/assets/linkedin_icon.png"),
steps: steps,
noGatewayIntegration: true,
} satisfies OAuthAppSpec;
Binary file added ui/admin/public/assets/linkedin_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.