n8n - 💡(How to fix) Fix LinkedIn node fails with 'refreshToken is required' for standard OAuth apps (no Marketing Developer Platform) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#29434Fetched 2026-04-29 06:34:56
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
commented ×1labeled ×1mentioned ×1subscribed ×1

The LinkedIn node crashes with NodeApiError: refreshToken is required (ERR_ASSERTION) when the stored OAuth credential does not contain a refresh token. This affects all standard LinkedIn apps that have not been approved for LinkedIn's Marketing Developer Platform (MDP).

Error Message

NodeApiError: refreshToken is required at ExecuteContext.linkedInApiRequest (nodes/LinkedIn/GenericFunctions.ts:71) at @n8n/client-oauth2/src/client-oauth2-token.ts → refresh()

Root Cause

LinkedIn only issues refresh tokens to apps approved for the Marketing Developer Platform. Standard apps using the "Share on LinkedIn" product receive a 60-day access token and no refresh token. This is documented LinkedIn behavior, not a user misconfiguration.

When the access token expires (or n8n attempts to refresh it), the call chain reaches:

client-oauth2-token.js → refresh() → a.ok(this.refreshToken, 'refreshToken is required')

This hard assertion throws an opaque ERR_ASSERTION error instead of a useful message.

Additionally, the LinkedInOAuth2Api credential definition does not include offline_access in its scope — and LinkedIn rejects offline_access for standard apps with invalid_scope_error: Unknown scope "offline_access" — so there is no way to obtain a refresh token through normal OAuth flow without MDP access.

Fix Action

Workaround

Re-authorize the LinkedIn credential before the 60-day access token expires. The node works correctly with a fresh (non-expired) access token.

Code Example

client-oauth2-token.jsrefresh() → a.ok(this.refreshToken, 'refreshToken is required')

---

{
  "errorMessage": "refreshToken is required",
  "errorDetails": {
    "rawErrorMessage": ["refreshToken is required"],
    "httpCode": "ERR_ASSERTION"
  }
}

---

NodeApiError: refreshToken is required
    at ExecuteContext.linkedInApiRequest (nodes/LinkedIn/GenericFunctions.ts:71)
    at @n8n/client-oauth2/src/client-oauth2-token.tsrefresh()

---

// Before
assert.ok(this.refreshToken, 'refreshToken is required');

// After
if (!this.refreshToken) {
  throw new Error('OAuth token expired and no refresh token is available. Please reconnect the credential.');
}
RAW_BUFFERClick to expand / collapse

Summary

The LinkedIn node crashes with NodeApiError: refreshToken is required (ERR_ASSERTION) when the stored OAuth credential does not contain a refresh token. This affects all standard LinkedIn apps that have not been approved for LinkedIn's Marketing Developer Platform (MDP).

Root Cause

LinkedIn only issues refresh tokens to apps approved for the Marketing Developer Platform. Standard apps using the "Share on LinkedIn" product receive a 60-day access token and no refresh token. This is documented LinkedIn behavior, not a user misconfiguration.

When the access token expires (or n8n attempts to refresh it), the call chain reaches:

client-oauth2-token.js → refresh() → a.ok(this.refreshToken, 'refreshToken is required')

This hard assertion throws an opaque ERR_ASSERTION error instead of a useful message.

Additionally, the LinkedInOAuth2Api credential definition does not include offline_access in its scope — and LinkedIn rejects offline_access for standard apps with invalid_scope_error: Unknown scope "offline_access" — so there is no way to obtain a refresh token through normal OAuth flow without MDP access.

Steps to Reproduce

  1. Create a standard LinkedIn app (no Marketing Developer Platform product)
  2. Add LinkedIn OAuth2 credential in n8n and connect via OAuth
  3. Run a workflow using the LinkedIn node
  4. Wait for the 60-day access token to expire (or revoke and reconnect)
  5. Run the workflow again → NodeApiError: refreshToken is required

Expected Behavior

When no refresh token is present and the access token is expired, n8n should throw a clear, actionable error:

"LinkedIn access token has expired. Please reconnect the credential."

Or better: attempt the request with the existing access token, and only surface the re-auth message on a 401 response.

Actual Behavior

{
  "errorMessage": "refreshToken is required",
  "errorDetails": {
    "rawErrorMessage": ["refreshToken is required"],
    "httpCode": "ERR_ASSERTION"
  }
}

Stack:

NodeApiError: refreshToken is required
    at ExecuteContext.linkedInApiRequest (nodes/LinkedIn/GenericFunctions.ts:71)
    at @n8n/client-oauth2/src/client-oauth2-token.ts → refresh()

Environment

  • n8n version: 2.16.1 (self-hosted)
  • Node.js: 22.22.2
  • LinkedIn app product: "Share on LinkedIn" (standard, no MDP)

Suggested Fix

In packages/@n8n/client-oauth2/src/client-oauth2-token.ts, replace the hard assertion:

// Before
assert.ok(this.refreshToken, 'refreshToken is required');

// After
if (!this.refreshToken) {
  throw new Error('OAuth token expired and no refresh token is available. Please reconnect the credential.');
}

Additionally, consider documenting in the LinkedIn credential or node description that refresh tokens require LinkedIn Marketing Developer Platform access, and that standard app tokens expire after 60 days.

Workaround

Re-authorize the LinkedIn credential before the 60-day access token expires. The node works correctly with a fresh (non-expired) access token.

extent analysis

TL;DR

Modify the client-oauth2-token.ts file to throw a clear error when no refresh token is available instead of a hard assertion.

Guidance

  • Identify if your LinkedIn app is approved for the Marketing Developer Platform (MDP) to determine if you can obtain a refresh token.
  • Verify that the LinkedInOAuth2Api credential definition does not include offline_access in its scope, which is required for refresh tokens.
  • Consider re-authorizing the LinkedIn credential before the 60-day access token expires as a temporary workaround.
  • Review the suggested fix in client-oauth2-token.ts to improve error handling for expired access tokens without refresh tokens.

Example

// Replace the hard assertion with a clear error message
if (!this.refreshToken) {
  throw new Error('OAuth token expired and no refresh token is available. Please reconnect the credential.');
}

Notes

This fix assumes that the issue is solely due to the absence of a refresh token for standard LinkedIn apps. If the app is approved for MDP, the issue may be different.

Recommendation

Apply the suggested workaround of re-authorizing the LinkedIn credential before the 60-day access token expires, as modifying the client-oauth2-token.ts file may require additional testing and validation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

n8n - 💡(How to fix) Fix LinkedIn node fails with 'refreshToken is required' for standard OAuth apps (no Marketing Developer Platform) [1 comments, 2 participants]