I want to create my design for my login and still use Auth0 authentication.
Im trying to get the token with the client’s email and password, and i get status 500.
i work with Nodejs and this is my code:
function options(email, password) {
return {
method: ‘POST’,
url: https://${auth0Config.auth0Domain}/oauth/token
,
headers: { ‘content-type’: ‘application/x-www-form-urlencoded’ },
data: new URLSearchParams({
grant_type: auth0Config.grant_type,
client_id: auth0Config.client_id,
client_secret: auth0Config.client_secret,
audience: auth0Config.audience,
username: email,
password: password,
scope: ‘read:sample’
})
}
};
async function findTokenWithPassword(email, password) {
try {
const option = options(email, password);
const response = await axios.request(option);
if (!response.status === 200) {
throw new Error('Invalid password/username');
}
return response;
} catch (error) {
throw error;
}
}
I appreciate getting any help.