Action to Store the Auth0 user id in a remote system doesnt work

Hello,

I’m attempting to use the Action that Stores the Auth0 user id in a remote system.

However, it doesn’t work. The error I get is simply:

“Error! API Error. Please contact Auth0 if error persists.”
Below this message, the second error message just shows up as a blank object: “Error: {}”

Here is my test code, which is completely based off of the example given by Auth0:

const axios = require("axios");

exports.onExecutePostUserRegistration = async (event) => {

  await axios.post("postgres://<my_environment_name>:<my_password>@john.db.elephantsql.com/<database name>/<table name>", { params: { email: event.user.email }});

};

I have set up my database exactly as per the instructions noted here. It is a web-based Elephant PostgresSQL database.

Note that the step to Create a user and send to that same external database works just fine for me (under Authentication, non Action- based). So, does the problem lie somewhere within the Actions API?

Thanks and Regards,

@rueben.tiow @dan.woda @konrad.sopala

Hi @robliou01,

Thanks for reaching out to the Auth0 Community!

Based on the doc you shared, it describes steps to configure PostgreSQL as an Auth0 Custom Database. However, you’re using a Post-User Registration Action to create the user in your PostgreSQL DB instead of the custom DB script.

Additionally, when looking at the axios.post request, I believe the issue involves POST-ing a Database URL instead of an HTTPS URL. I can confirm after testing this in the Actions debugger interface.

Given that, I recommend completing the configuration for your custom database with PostgreSQL and implementing the Create script. This should create a user whenever a user signs up on your application using this connection. See below.

Please let me know how this works for you.

Thanks.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.