{"library":"remix-auth-linkedin","title":"Remix Auth Linkedin Strategy","description":"This library provides a LinkedIn authentication strategy for `remix-auth`, enabling users to log into Remix applications via their LinkedIn accounts. It extends `remix-auth-oauth2` and is currently at version 2.0.1, shipping with full TypeScript definitions for robust development. The package maintains a steady release cadence, with recent updates focused on dependency upgrades and critical API changes. A significant update in version 2.0.0 involved transitioning from LinkedIn's legacy OAuth 2.0 flow to the newer OpenID Connect standard, reflecting LinkedIn's evolving authentication protocols. This change required corresponding adjustments in application setup and profile handling. `remix-auth-linkedin` supports both Node.js and Cloudflare runtimes, making it versatile for various Remix deployment environments. Developers must register an OAuth application on the LinkedIn Developers page to obtain the necessary `clientID` and `clientSecret` for integration. It seamlessly integrates with `remix-auth`'s session management, leveraging `createCookieSessionStorage` or similar for authentication persistence.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install remix-auth-linkedin"],"cli":null},"imports":["import { LinkedinStrategy } from \"remix-auth-linkedin\";","import { Authenticator } from \"remix-auth\";","import { createCookieSessionStorage } from '@remix-run/node';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createCookieSessionStorage } from '@remix-run/node';\nimport { Authenticator } from 'remix-auth';\nimport { LinkedinStrategy } from \"remix-auth-linkedin\";\n\n// Personalize this options for your usage.\nconst cookieOptions = {\n\tpath: '/',\n\thttpOnly: true,\n\tsameSite: 'lax' as const,\n\tmaxAge: 24 * 60 * 60 * 1000 * 30,\n\tsecrets: [process.env.SESSION_SECRET ?? 'fallback_secret_for_dev_only'], // Use env variable for production\n\tsecure: process.env.NODE_ENV !== 'development',\n};\n\nconst sessionStorage = createCookieSessionStorage({\n\tcookie: cookieOptions,\n});\n\nexport const authenticator = new Authenticator<string>(sessionStorage, {\n\tthrowOnError: true,\n});\n\nconst linkedinStrategy = new LinkedinStrategy(\n   {\n      clientID: process.env.LINKEDIN_CLIENT_ID ?? 'YOUR_CLIENT_ID_FROM_ENV',\n      clientSecret: process.env.LINKEDIN_CLIENT_SECRET ?? 'YOUR_CLIENT_SECRET_FROM_ENV',\n      callbackURL: process.env.LINKEDIN_CALLBACK_URL ?? 'https://example.com/auth/linkedin/callback',\n   },\n   async ({accessToken, refreshToken, extraParams, profile, context}) => {\n      // In a real application, you would interact with your database or API here\n      // For example, finding or creating a user based on the LinkedIn profile\n      console.log('LinkedIn Profile:', profile.id, profile.displayName, profile.emails[0].value);\n      console.log('Access Token:', accessToken);\n      // Simulate user data storage\n      return { id: profile.id, email: profile.emails[0].value, name: profile.displayName };\n   }\n);\n\nauthenticator.use(linkedinStrategy, 'linkedin');\n\n// app/routes/login.tsx\n// export default function Login() {\n//    return (\n//       <form action=\"/auth/linkedin\" method=\"post\">\n//          <button>Login with Linkedin</button>\n//       </form>\n//    )\n// }\n\n// app/routes/auth/linkedin.tsx\n// import { ActionFunction } from '@remix-run/node';\n// import { authenticator } from '~/linkedin.server'; // Adjust path\n//\n// export let loader: ActionFunction = () => { throw new Response(null, { status: 404 }); }; // Loader is not strictly needed here\n// export let action: ActionFunction = ({ request }) => {\n//    return authenticator.authenticate('linkedin', request);\n// };\n\n// app/routes/auth/linkedin/callback.tsx\n// import { LoaderFunction } from '@remix-run/node';\n// import { authenticator } from '~/linkedin.server'; // Adjust path\n//\n// export let loader: LoaderFunction = ({ request }) => {\n//    return authenticator.authenticate('linkedin', request, {\n//       successRedirect: '/dashboard',\n//       failureRedirect: '/login',\n//    });\n// };","lang":"typescript","description":"This code snippet demonstrates the setup of `LinkedinStrategy` with `remix-auth`, including session storage configuration and the essential authentication callback, providing a foundation for user login workflows.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}