Skip to content

Instantly share code, notes, and snippets.

@abiral
Created September 19, 2022 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abiral/cac024a849661dff43842758ac4104c9 to your computer and use it in GitHub Desktop.
Save abiral/cac024a849661dff43842758ac4104c9 to your computer and use it in GitHub Desktop.
const axios = require("axios").default;
const CLIENT_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
const CLIENT_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
const PHONE = process.argv[2];
const DOMAIN = 'xxxxxx.us.auth0.com';
const options = {
method: 'POST',
url: `https://${DOMAIN}/passwordless/start`,
headers: {'content-type': 'application/json'},
data: {
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
connection: 'sms',
phone_number: PHONE,
send: 'code'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
const axios = require("axios").default;
const CLIENT_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
const CLIENT_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
const PHONE = '+xxxxxxxxxxxxx;
const DOMAIN = 'xxxxxx.us.auth0.com';
const OTP = process.argv[2];
const options = {
method: 'POST',
url: `https://${DOMAIN}/oauth/token`,
headers: {'content-type': 'application/json'},
data: {
grant_type: 'http://auth0.com/oauth/grant-type/passwordless/otp',
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
username: PHONE,
otp: OTP,
realm: 'sms',
audience: 'http://localhost:4000',
scope: 'openid profile email'
}
};
axios.request(options).then(function (response) {
console.log(response.data.access_token);
}).catch(function (error) {
console.error(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment