Auth0

The Auth0 connection is a user provider that automatically imports your users and keeps them up-to-date in UserHub.

To enable the Auth0 connection, you'll need to create a machine-to-machine application type and optionally add the UserHub action to your Auth0 tenant.

Create an Auth0 application

  1. Go to the Auth0 dashboard
  2. Switch to the tenant you want to set up in UserHub
  3. Click Applications and then Applications again
  4. Click the Create Application button
  5. Enter UserHub for the Name
  6. Select Machine to Machine for the Application type
  7. Click Create
  8. When prompted, select the Auth0 Management API
  9. Select the following permissions: read:users, update:users, delete:users, and create:users
  10. Click Authorize
  11. Take note of the Client ID from the header and the Client Secret from the Credentials tab, you'll need these in the next step

Setup connection

Next, you will need to set up the connection in the UserHub Admin console.

  1. Go to Connections in the Developers dropdown of the Tenant settings.
  2. Click the Setup button for Auth0
  3. Enter your Auth0 Domain (this must end with auth0.com)
  4. Enter the Client ID and Client Secret you created above
  5. Click Save
  6. Make sure the status switches to Active

Copy the newly created connection ID (e.g. conn_obXdd...), as this will be used in the next step.

Optional: setup Portal callback

Next, you have the option of using Auth0's sign-in interface instead of implementing the Portal callback handler.

Create app for callback

  1. Go to the Auth0 dashboard
  2. Switch to the tenant you set up above
  3. Click Applications and then Applications again
  4. Click the Create Application button
  5. Enter Billing for the Name (or whatever you prefer)
  6. Select Regular Web for the Application type
  7. Click Create
  8. Click the Settings tab
  9. Enter https://<portal-domain>/ for Application Login URI (you can find this URL in the Admin console Portal settings)
  10. Enter https://<portal-domain>/signin for Allowed Callback URLs
  11. Enter https://<portal-domain>/signout for Allowed Logout URLs
  12. Click Save Changes
  13. Note the Client ID and Client secret, you'll need it in the next step

Add app settings to connection

  1. Go to Connections from the UserHub Admin console Developers dropdown
  2. Click Auth0
  3. Click the Edit connection button
  4. Click Enable Portal sign-in
  5. Enter the App client ID and App client secret you noted above and click Save

You should now be able to open https://<portal-domain>/ in your browser and sign in.

Optional: setup Auth0 Action

The UserHub Auth0 Action ensures your users are immediately synced with UserHub on sign-in.

To set up the UserHub Auth0 Action, you'll need the UserHub Auth0 connection ID (see above) and an Admin API key scoped to Auth0.

Create API key

  1. Go to the Admin console and click API keys via the Developers dropdown or Tenant settings
  2. Click New API key
  3. Enter Auth0 Action for the Description
  4. Select Admin API for the Type
  5. Don't set an expiration
  6. Click the Integrations dropdown and select Auth0
  7. Click Create
  8. Note the generated API key (e.g. sk_agX...), as this token will be used in the next step

Setup action

Next, you'll need to set up the UserHub action in Auth0:

  1. Go the the Auth0 dashboard

  2. Switch to the desired Auth0 tenant

  3. Click Actions and then Library in the left menu

  4. Click Build Custom

  5. Enter UserHub for the Name

  6. Select Login / Post Login as the Trigger

  7. Select the latest recommended Node Runtime

  8. Click Create

  9. Replace the code with the following snippet:

    const { UserHubActions } = require("@userhub/auth0-actions");
    
    exports.onExecutePostLogin = async (event, api) => {
      const actions = new UserHubActions({
        apiKey: event.secrets.API_KEY,
        connectionId: event.secrets.CONNECTION_ID,
      });
    
      await actions.postLogin(event);
    };
    
  10. Click the Dependencies icon in the left panel and Add Dependency to add the UserHub dependency: @userhub/auth0-actions

  11. Click the Secrets icon in the left panel and click Add Secret

  12. Enter API_KEY for the Key

  13. Enter the Admin API key you generated above for the Value

  14. Click Create

  15. Click Add Secret again

  16. Enter CONNECTION_ID for the Key

  17. Enter the connection ID you noted in step 2 for the Value (e.g. conn_obXdd...)

  18. Click Create

  19. Click Deploy

  20. Click Flows under Actions in the left menu

  21. Click the Login card

  22. Click the Custom tab on the right

  23. Drag the UserHub action so that it's positioned between the Start and End nodes

  24. Click Apply

PreviousAmazon Cognito
NextCustom users

Turn users intorevenue
$

Subscribe to monthly product updates

© 2024 UserHub

Integrations

    UserHub & Auth0UserHub & Stripe BillingUserHub & Google CloudUserHub & FirebaseUserHub & custom auth