Hi,
I’m linking two accounts using the identities endpoint as follows. Post linking, I want to redirect to my site as the primary user. However, after the following call, I end up with a 500 error (Oops!, something went wrong server_error: Internal error). Is anyone able to help me understand what might be wrong?
In the following, the ${fullTargetId} is the existingIdentity.provider+“|”+existingIdentity.user_id
and the ${newToken} is the token for the Auth0 Management API.
The call below does link the new account into the existing one with the expected Raw JSON.
const url = `https://${event.secrets.domain}/api/v2/users/${fullTargetId}/identities`;
var options = {
method: 'POST',
url: url,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${newToken}`
},
data: {
"provider": event.connection.strategy,
"connection_id": event.connection.id,
"user_id": event.user.user_id
}
};
await axios.request(options).then(function (response) {
console.log(response.data);
api.redirect.sendUserTo("http://localhost:3000");
}).catch(function (error) {
console.error(error);
});