Skip to content

Instantly share code, notes, and snippets.

@amacal
Created November 4, 2020 07:56
Show Gist options
  • Save amacal/52a5994c74530a5cb70fc2f272eb0459 to your computer and use it in GitHub Desktop.
Save amacal/52a5994c74530a5cb70fc2f272eb0459 to your computer and use it in GitHub Desktop.
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