Skip to content

Instantly share code, notes, and snippets.

@gnschenker
Created December 30, 2019 16:03
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 gnschenker/5179be9b93add328e14e6655093ae689 to your computer and use it in GitHub Desktop.
Save gnschenker/5179be9b93add328e14e6655093ae689 to your computer and use it in GitHub Desktop.
Logic to retrieve the token from Auth0
const axios = require('axios');
var Config = require('config-js');
var config = new Config('./config/config.js');
module.exports = {
getToken: async () => {
const url = config.get("auth0.url");
const body = {
client_id: config.get("auth0.client_id"),
client_secret: config.get("auth0.client_secret"),
audience: config.get("auth0.audience"),
grant_type: "client_credentials"
};
const response = await axios.post(url, body);
token = response.data.access_token;
return token;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment