Account linking through Actions

Hi,

lately I’ve been struggling with simple email account linking. I’ve tried the “Account Linking Extension”, but it turned out not to be an option for my use case, because it requires the user to manually confirm the linking though the UI.

Then I tried to use actions (specifically the “Post login” flow) and it indeed links accounts with the same email addresses, but then it returns the original user id.

For example:

  1. I sign in with GitHub (github|...)
  2. I sign out
  3. I sign in again in with username/password (auth0|...)
  4. Action correctly links the profile, but it returns the original username/password identity (auth0|...). I’d expect to receive the primary user id (github|...)

To link accounts I used the /link endpoint in the Management API v2.

Is there a way how to return the primary user id after account linking?

1 Like

Hello,
It is important to set the event.user object to the primary user after the accounts have been linked in the action. Doing this should return the github user_id as a sub claim in the id_token/access token you receive to your application.

Below is a similar post that could be helpful.

Let us know how it goes!

Hi Praveen, thank you for your reply :slight_smile:

I’ve tried this before, but now I tried it again just in case I was doing something wrong. Unfortunately it seems that neither assigning to the event.user or returning it has any effect whatsoever.

I think this was possible before, but now it seems it’s not possible (at least according to your docs):

I’ll share the full code of the action just in case I’m doing something wrong:

Thank you.

Hi there.

This does not seem to be working.

I set event.user=murgedUser however, the access token still contains the original users data :frowning:

I’m not sure if I’'m reading this correctly, but I assume this means, that it is no longer possible to edit the access token without the use of api.command or am I missing something?