[Actions][AccountLinking] How to do Account Linking from a PostLogin Action?

Hi! Hope your are doing well!!

TL;DR: Is currently a way to get access to the ManagementAPI to do account linking from Actions?

Long explanation:
I have been trying to do seamlessly account linking of previously created Database users with Google OAuth2 users with the new Actions feature, I understand that this should be done using de ManagementAPI that is available from the “auth0” npm package.

For this I require some credentials that were previously available from the context object (here) which is no longer available after the Actions GA Programming Model update.

Is currently a way to get access to the ManagementAPI to do account linking from Actions?


Solution Explanation:
Also, I was really confused, because the context parameter has been removed from the actions functions signature as stated here.

Secrets were moved from:

async function myFunction(event, context) {
    console.log(context.secrets);
}

to:

exports.onExecutePostLogin = async (event, api) => {
  console.log(event.secrets);
}

Finally, I did not realize that ManagementAPI can be used with

var auth0 = new ManagementClient({
  domain: '{YOUR_ACCOUNT}.auth0.com',
  clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}',
  clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}',
  scope: 'read:users update:users'
});

The credentials in the above example er simply “secrets”, and nothing “special” .

1 Like

Oh, ok, I see now! I was looking for some kind of accessToken, my bad. Thanks!

Also, I was really confused, because the context parameter has been removed from the actions functions signature as stated here.

Secrets were moved from:

async function myFunction(event, context) {
    console.log(context.secrets);
}

to:

exports.onExecutePostLogin = async (event, api) => {
  console.log(event.secrets);
}
1 Like

No worries. I spent quite some time on the Auth0 platform - you can always reach out if you have any questions :relaxed:

1 Like