Progammatic login into organization

As this thread was closed: Auth0 password grant with organization - #4 by rueben.tiow

@Hawxy you mentioned it’s on the Auth0 Roadmap for the end of 2022. Any update on this? Can’t find documentation about it. It was closed by @konrad.sopala so I assume it is solved?

M2M tokens w/ Organizations is actively being worked on, I’ve been involved with some user research aspects. If you’re on an enterprise plan you can reach out to TAM for more information.

Thanks for the quick reply. Unfortunately we are not on an enterprise plan.

I’m also curious about updates - just ran into this same problem.

Hi everyone!

In the context of performing automated tests in the context of organizations, it can be a difficult task since the usual ROPG grant flow cannot be enabled.

However, this can be resolved by using a Custom Token Exchange Trigger in which you will be able to set the organization as seen in this example:

exports.onExecuteCustomTokenExchange = async (event, api) => {

  // 1. Validate subject_token
  const subject_token = await validateToken(event.transaction.subject_token, jwksUri);

  // 2.  Apply your authorization policy on the user
  const isAuthorized = await authorizeAccess(subject_token.sub);
  if (!isAuthorized) {
    api.access.deny('Unauthorized_login', 'User cannot login due to reason: X');
  }

  // 3. Set the user for the transaction
  api.authentication.setOrginzation('org_xS525r979AS33MSf');

  // 4. Set the user for the transaction. You may also use setUserByConnection()
  api.authentication.setUserById(subject_token.sub);

  return;
};

Hope this helps anybody who stumbles across the same issue!

Kind Regards,
Nik