{"record":{"id":"a22a2632ec960c8d","repo":"jackwener/OpenCLI","slug":"could-not-resolve-sales-navigator-auth-token-for-r","errorCode":null,"errorMessage":"Could not resolve Sales Navigator auth token for recipient","messagePattern":"Could not resolve Sales Navigator auth token for recipient","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/salesnav-message.js","lineNumber":226,"sourceCode":"      profileId: decodeURIComponent(urlMatch[1]),\n      authType: decodeURIComponent(urlMatch[2]),\n      authToken: decodeURIComponent(urlMatch[3]),\n      entityUrn: `urn:li:fs_salesProfile:(${decodeURIComponent(urlMatch[1])},${decodeURIComponent(urlMatch[2])},${decodeURIComponent(urlMatch[3])})`,\n    };\n  }\n  for (const resource of probe?.resourceUrns || []) {\n    const resourceMatch = String(resource).match(/profileId:([^,)]+),authType:([^,)]+),authToken:([^,)]+)\\)/);\n    if (resourceMatch && resourceMatch[1] === parsed.profileId) {\n      return {\n        profileId: resourceMatch[1],\n        authType: resourceMatch[2],\n        authToken: resourceMatch[3],\n        entityUrn: `urn:li:fs_salesProfile:(${resourceMatch[1]},${resourceMatch[2]},${resourceMatch[3]})`,\n      };\n    }\n  }\n  void csrf;\n  throw new CommandExecutionError('Could not resolve Sales Navigator auth token for recipient', `Observed URL: ${probe?.href || 'url_not_available'}\\nBody: ${normalizeWhitespace(probe?.text || '').slice(0, 500)}`);\n}\n\nfunction profileSummary(json) {\n  const data = json?.data || json || {};\n  const pos = data.defaultPosition || (Array.isArray(data.positions) ? data.positions.find((p) => p.current) || data.positions[0] : {}) || {};\n  return {\n    recipient: normalizeWhitespace(data.fullName || [data.firstName, data.lastName].filter(Boolean).join(' ')),\n    title: normalizeWhitespace(pos.title || data.headline || ''),\n    company: normalizeWhitespace(pos.companyName || pos.company?.name || ''),\n    degree: normalizeWhitespace(data.degree || ''),\n    inmail_restriction: normalizeWhitespace(data.inmailRestriction || ''),\n    open_link: Boolean(data.memberBadges?.openLink),\n  };\n}\n\nfunction requireProfileSummary(json) {\n  const summary = profileSummary(json);\n  if (!summary.recipient) {","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/salesnav-message.js#L208-L244","documentation":"When the --recipient was only partially resolvable (e.g. a /in/ URL with empty authType/authToken), resolveRecipient opens the Sales Navigator lead page and probes the DOM for the full profile triple. If the probe can't recover the auth token, it throws CommandExecutionError with the observed URL and a 500-char body snippet as detail.","triggerScenarios":"The lead page redirected (profile not viewable, no Sales Nav seat, logged-out redirect), the DOM deco object never rendered within the 6s wait, or the probe text didn't match the expected resource pattern.","commonSituations":"Recipient lacks a Sales Navigator profile (only a plain LinkedIn account); viewing limit reached on Sales Nav; LinkedIn layout change altering the embedded profile deco; page still loading when probed.","solutions":["Review the detail: Observed URL + body snippet shows where the flow ended","Supply a fully-qualified urn:li:fs_salesProfile:(...) or Sales Nav lead URL so no resolution is needed","Confirm the recipient exists in Sales Navigator (search for them first)","Increase wait time or retry if the page was still loading"],"exampleFix":"// before\n--recipient \"https://www.linkedin.com/in/jane-doe/\"\n// after\n--recipient \"urn:li:fs_salesProfile:(ACoAAAabc,ACoAAUTH,token123)\"","handlingStrategy":"try-catch","validationCode":"// Prefer fully-resolved inputs so no DOM resolution is needed\nconst fullyResolved = /^urn:li:fs_salesProfile:\\([^,()]+,[^,()]+,[^,()]+\\)$/.test(recipient.trim());\nif (!fullyResolved) console.warn('recipient will be resolved via Sales Nav page probe; ensure a Sales Nav seat & viewable profile');","typeGuard":"const isResolvedUrn = (v) => {\n  const m = /^urn:li:fs_salesProfile:\\(([^,()]+),([^,()]+),([^,()]+)\\)$/.test(v || '');\n  return m && !/undefined|null|not_available/i.test(v);\n};","tryCatchPattern":"try {\n  recipient = await resolveRecipient(page, parsed, csrf);\n} catch (err) {\n  if (/Could not resolve Sales Navigator auth token/.test(err.message)) {\n    console.error(err.detail); // shows Observed URL + body snippet\n    // ask user for a fully-qualified urn or verify Sales Nav access\n  } else throw err;\n}","preventionTips":["Pass fully-qualified salesProfile urns to skip resolution","Confirm the recipient actually exists in Sales Navigator","Retry if the page was still loading (increase wait)","Read the error's detail — it includes the final URL and body excerpt"],"tags":["linkedin","sales-navigator","resolution-failed","scraping"],"backgroundTag":"profile-resolution-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}