Action - User does not exist after account linking

Hi, I’m using the action feature in Auth0, specifically the endpoint api/v2/users/${userId}/identities for merging user accounts, which is working as expected. However, I’m encountering an issue. If I create a user in Auth0 and then attempt to log in with Google for the first time, I get the following error:

"error": {
  "message": "The user does not exist.",
  "oauthError": "access_denied",
  "type": "oauth-authorization"
}

The issue is resolved after I try to log in again. Any suggestions or changes to address this?


1 Like

Hello @dvir, in order to use account linking in actions you will need first link accounts via management api then call api.authentication.setPrimaryUser with the new user id
you will need to use setPrimaryUser to change the authenticating user in the authentication context after linking accounts; fail to do but only calling the management api does not change the primary user in the actions execution context. hence it result to the failed log in.

The purpose of the setPrimaryUser feature allow the first login to have the new user id in context rather than having it fail once a an user account is linked. when those accounts are linked via the mgmt api, the account they’re signing in from no longer exists so it fails

you can find more details (code line 122) in our doc for best practice

1 Like