Created
November 4, 2020 07:56
-
-
Save amacal/52a5994c74530a5cb70fc2f272eb0459 to your computer and use it in GitHub Desktop.
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'); | |
const querystring = require('querystring'); | |
module.exports = async function({ Username, Password }) { | |
const result = await axios({ | |
method: 'post', | |
url: 'https://login.microsoftonline.com/common/oauth2/token', | |
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, | |
data: querystring.stringify({ | |
client_id: 'ea0616ba-638b-4df5-95b9-636659ae5121', | |
grant_type: 'password', | |
username: Username, | |
password: Password, | |
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', | |
resource: 'https://analysis.windows.net/powerbi/api' | |
}), | |
}); | |
return result.data.access_token; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment