Created
December 30, 2019 16:03
-
-
Save gnschenker/5179be9b93add328e14e6655093ae689 to your computer and use it in GitHub Desktop.
Logic to retrieve the token from Auth0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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