Open ghost opened 10 months ago
Hi @misuvii - thanks for raising this
Due to this, one can't simply extract identitites from a user profile and loop it to link as suggested in the documentation, Since it throws a type mismatch error for provider.
Could you share the code that raises the error? (and a link to the documentation)
@adamjmcgrath This is the code that raises the error
const mergeMetadataAndLinkUsersTask = async (
secondary: GetUsers200ResponseOneOfInner,
identity: GetUsers200ResponseOneOfInnerIdentitiesInner,
) => {
// Include user & app metadata
const mergedUserMetadata = merge({}, secondary.user_metadata, primary.user_metadata);
const mergedAppMetadata = merge({}, secondary.app_metadata, primary.app_metadata);
const updateUserTask = async () => {
await client.users.update(
{ id: primary.user_id! },
{
user_metadata: mergedUserMetadata,
app_metadata: mergedAppMetadata,
},
);
};
const linkUsersTask = async () => {
await client.users.link(
{ id: primary.user_id! },
{
user_id: secondary.user_id!,
provider: identity.provider, // Here identity.provider is a string, but the method expects it to be of type PostIdentitiesRequestProviderEnum
},
);
};
await Promise.all([updateUserTask(), linkUsersTask()]);
};```
Thanks for clarifying @misuvii - I've raised this with the team that owns those endpoints, will see if we can get this changed.
In the meantime, you can safely cast the identity.provider
property as PostIdentitiesRequestProviderEnum
const linkUsersTask = async () => {
await client.users.link(
{ id: primary.user_id! },
{
user_id: secondary.user_id!,
provider: identity.provider as PostIdentitiesRequestProviderEnum,
}
);
};
Also hit this issue today, will use typecasting to bypass for now
Checklist
Description
The field
provider
is defined asstring
in the interfacesUserIdentities
andGetUsers200ResponseOneOfInnerIdentitiesInner
. But for the methodlink
inusers
section of the management api client, the optional fieldprovider
in the bodyParameters of typePostIdentitiesRequest
is defined asPostIdentitiesRequestProviderEnum
. Due to this, one can't simply extract identitites from a user profile and loop it to link as suggested in the documentation, Since it throws a type mismatch error forprovider
.Reproduction
The scenario is finding every account with same email id and linking it together.
Additional context
No response
node-auth0 version
4.0.1
Node.js version
18