Hello,
I’m new to Auth0 and have been struggling to implement it into our PHP application. I have the following database action script:
function login(email, password, callback) {
const request = require('request');
request.get({
url: 'https://mydomain.example/[...],
auth: {
username: email,
password: password
}
}, function(err, response, body) {
console.log("We have a response");
if (err || response.statusCode === 401){
console.log("We hit a problem");
return callback();
}
console.log("All looks normal");
const resp = JSON.parse(body);
const user = resp.user[0];
callback(null, {
user_id: user.user_id.toString(),
nickname: user.name,
email: user.email
});
});
}
If I run this from the DB Action Script page, using “Save and Try”, I get the user profile etc. but if I run this using the “Try Connection” (the Universal Login) I get a username or password issue. This is despite the console.log message showing that it had in fact gotten through to the success state which was also shown on the server side log.
Any ideas? I can’t find much documentation on what it is actually expecting as a callback. Our server will return 401 if the username and password fail.
Thanks