fix(linkedin): add mandatory parameters (expiresOn, api_url) for Unipile connection link generation
This commit is contained in:
parent
3571982c7e
commit
3012c11b42
1 changed files with 9 additions and 2 deletions
|
|
@ -29,9 +29,16 @@ export async function POST() {
|
|||
|
||||
const type = profile?.unipile_account_id ? "reconnect" : "create";
|
||||
|
||||
// expiresOn: 1 hour from now (links also expire on daily restart regardless)
|
||||
const expiresOn = new Date(Date.now() + 60 * 60 * 1000).toISOString();
|
||||
// api_url must be the full Unipile server URL derived from the DSN
|
||||
const api_url = `https://${dsn}`;
|
||||
|
||||
const body: Record<string, unknown> = {
|
||||
type,
|
||||
providers: ["LINKEDIN"],
|
||||
expiresOn,
|
||||
api_url,
|
||||
notify_url: `${appUrl}/api/linkedin/callback`,
|
||||
success_redirect_url: `${appUrl}/dashboard/settings/account?linkedin=connected`,
|
||||
failure_redirect_url: `${appUrl}/dashboard/settings/account?linkedin=failed`,
|
||||
|
|
@ -39,9 +46,9 @@ export async function POST() {
|
|||
name: userData.user.id,
|
||||
};
|
||||
|
||||
// For reconnect we need the existing account_id
|
||||
// For reconnect, the field is reconnect_account (not account_id)
|
||||
if (type === "reconnect" && profile?.unipile_account_id) {
|
||||
body.account_id = profile.unipile_account_id;
|
||||
body.reconnect_account = profile.unipile_account_id;
|
||||
}
|
||||
|
||||
const response = await fetch(`https://${dsn}/api/v1/hosted/accounts/link`, {
|
||||
|
|
|
|||
Loading…
Reference in a new issue