LinkedIn OAuth provider

OAuth integration for LinkedIn. Refer to LinkedIn OAuth documentation for getting the required credentials. Provider id is linkedin.

import { linkedIn } from "@lucia-auth/oauth/providers";
import { auth } from "./lucia.js";

const linkedInAuth = linkedIn(auth, config);

linkedIn()#

const linkedIn: (
	auth: Auth,
	config: {
		clientId: string;
		clientSecret: string;
		redirectUri: string;
		scope?: string[];
	}
) => LinkedInProvider;
Parameters#

Scope profile and openid are always included.

nametypedescriptionoptional
authAuthLucia instance
config.clientIdstringLinkedIn OAuth app client id
config.clientSecretstringLinkedIn OAuth app client secret
config.redirectUristringLinkedIn OAuth app redirect uri
config.scopestring[]an array of scopes
Returns#
typedescription
LinkedInProviderLinkedIn provider

Interfaces#

LinkedInAuth#

See OAuth2ProviderAuth.

// implements OAuth2ProviderAuth<LinkedInAuth<_Auth>>
interface LinkedInAuth<_Auth extends Auth> {
	getAuthorizationUrl: () => Promise<readonly [url: URL, state: string]>;
	validateCallback: (code: string) => Promise<LinkedInUserAuth<_Auth>>;
}
Generics#
nameextendsdefault
_AuthAuthAuth

LinkedInTokens#

type LinkedInTokens = {
	accessToken: string;
	accessTokenExpiresIn: number;
	refreshToken: string;
	refreshTokenExpiresIn: number;
};

LinkedInUser#

type LinkedInUser = {
	sub: string;
	name: string;
	email: string;
	email_verified: boolean;
	given_name: string;
	family_name: string;
	locale: {
		country: string;
		language: string;
	};
	picture: string;
};

LinkedInUserAuth#

Extends ProviderUserAuth.

interface LinkedInUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> {
	linkedInUser: LinkedInUser;
	linkedInTokens: LinkedInTokens;
}
propertiestypedescription
linkedInUserLinkedInUserLinkedIn user
linkedInTokensLinkedInTokensAccess tokens etc
Generics#
nameextends
_AuthAuth