Link accounts
Learn how to link a LinkedIn account with Unipile API.
How does it work ?
To link a LinkedIn account with Unipile, you can offer users two authentication methods:
- Using credentials (email & password) - A new session is created for Unipile and will appear in the Active sessions list in LinkedIn settings. This session can be revoked at any time by ending it from LinkedIn. When revoked, the account status changes to
disconnected(🟡 Authentication required). - Using cookies (li_at & li_a) - The session is shared from an existing browser session where the cookies were collected. If the user logs out from that browser, the account will become
disconnected(🟡 Authentication required).
RecommendationsIf you want to use Recruiter features, it's recommended to authenticate accounts using cookies for better compatibility.
About premium products
LinkedIn’s core platform — its social network — is available to all users for free. It is referred to as the Classic product in Unipile.
In addition, users of LinkedIn can subscribe to access to paid products:
- Recruiter, the Recruiting Platform
- Sales Navigator, the Sales Intelligence Software
- Premium, the Classic Career Management Features
- Pages, the Company Page tool
By default, you can only call methods and receive real-time events for the Classic product, even if the account is subscribed to premium products.
To enable access to methods and events for premium products, specify the desired products during authentication as mentioned in the following sections.
You will not be able to call methods or receive events for an enabled product if the authenticated account is not subscribed to it.
Here is a summary of expected responses based on the subscribed and enabled products :
| Subscribed products | Unipile enabled products | List Recruiter chats response |
|---|---|---|
| None | Classic | 403 api/insufficient_permissions |
| None | Classic + Recruiter | 403 provider/insufficient_permissions |
| Recruiter | Classic | 403 api/insufficient_permissions |
| Recruiter | Classic + Recruiter | OK |
Link with Hosted Authentication
To link LinkedIn accounts using Hosted Authentication, follow the Authenticate with Hosted Auth guide.
At the Create Auth Link step:
- Set
LINKEDINas theproviders. - By default, Hosted Authentication only displays the credentials method. To also allow the cookies method, include it in the
allow_methodsfield of the LinkedIn configuration. - As mentioned before, only classic is enabled by default. If you need access to premium products, specify them in the
config.linkedin.productsfield.
Server code
// ...
const response = await unipile
.hostedAuth
.createAuthLink({
providers: "LINKEDIN",
expires_on: dayjs().add(10, 'minutes').toISOString()
redirect_uri: "https://myapp.com/link-account/callback",
config: {
linkedin: {
allow_methods: ["credentials", "cookies"],
products: ["classic", "sales_navigator"],
}
}
});
// ...# ...
response = hosted_auth_api.create_auth_link(
{
"providers": "LINKEDIN",
"expires_on": "2025-05-05T00:00:00.000Z",
"redirect_uri": "https://myapp.com/link-account/callback",
"config": {
"linkedin": {
"allow_methods": ["credentials", "cookies"],
"products": ["classic", "sales_navigator"],
}
},
}
)
# ...curl --request POST \
--url https://api.unipile.com/v2/auth/link \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"providers": "LINKEDIN",
"redirect_uri": "https://myapp.com/link-account/callback",
"expires_on": "2025-05-05T00:00:00.000Z",
"config": {
"linkedin": {
"allow_methods": ["credentials", "cookies"],
"products": ["classic", "sales_navigator"]
}
}
}
'Link with Custom Authentication
To build a custom authentication wizard for LinkedIn Accounts, follow the Credentials Flow guide.
As mentioned before, only classic is enabled by default. If you need access to premium products, specify them in the config.products field at the Collect credentials step, when submitting the form
Client code
const data = await startAuthIntent({
provider: "linkedin",
credentials: {
username,
password,
},
config: {
products: ["classic", "sales_navigator"],
}
});To let users authenticate with cookies, create a form that takes the main cookie li_at (access_token) and a premium cookie li_a (premium_access_token) required to enable Sales Navigator and Recruiter. Then, forward the values the same way instead of username and password.
Client code
const data = await startAuthIntent({
provider: "linkedin",
credentials: {
access_token,
premium_access_token,
},
config: {
products: ["classic", "sales_navigator"],
}
});Browser extension workflow example
If your application has a browser extension, you can benefit from users' LinkedIn session to make an authentication-less connection of their account.
Collect authentication data
Using your browser extension, collect the following :
li_at(andli_afor premium products) cookies from the logged in LinkedIn session- The User agent of the current browser
- The IP address (for Unipile, use a country-based IP)
Send all this data to your backend at regular intervals, so you can always have the most up-to-date picture of the user's LinkedIn session.
Connect the account to Unipile
Once you receive the first data collection, you can initiate the account connection to Unipile with our Custom authentication using the cookies method. Save the account ID.
It may happen that the account gets disconnected during its lifecycle. If you get such webhook notification, try to reconnect the account to Unipile with the last recorded data collection from the LinkedIn session, and the corresponding account ID.
If reconnection fails, retry every hour for 4 hours (to accommodate LinkedIn downtimes), allowing users time to reconnect and use their extension naturally.
Updated 28 days ago