Add parameters to callback URL

Hi,

I would like to connect my own database to Auth0 with this database action script:

function login(email, password, callback) {
  const msg = 'Error: Check login.py script';
  const fetch = require('node-fetch');
	const options = {
    method: "POST",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json;charset=UTF-8",
    },
    body: JSON.stringify({ email: email, password: password }),
  };
  
  fetch( configuration.server_url + "api-token-auth/", options).then((res) => {
		if (res.status === 200) {
      	return callback(null, {user_id: email});
       }
    else {
      return callback(new Error(msg));
    }
  });
}

My question is, is it possible to add the user’s email to the callback URL?

Thanks.

Hi @filtpod

I am pretty sure you cannot, but why do you want to?

The email will be present in the ID token as the user id field.

John

2 Likes

Hey John,

Thanks for the reply. I am having trouble accessing the user id.

When I was returned to the callback URL after successful authentication, I tried to access the email with the following

const { user, isAuthenticated, isLoading } = useAuth0();
const email = user_id

but user is “undefined” and isAuthenticated is “false”.

Why is that?

Hi @filtpod

That’s a different issue, and I can’t help much with that. If isAuthenticated is false, the user isn’t logged in and you won’t be able to get the user ID.

I’d suggest starting with the quickstart for Javascrsipt or whatever stack you are using, and making it work there, then adapting towards your current code.

John