Created
February 6, 2018 18:08
-
-
Save nbellocam/b2cb28d8ed79f51a4bcd891bb537a6f2 to your computer and use it in GitHub Desktop.
Calling Microsoft Graph API from an Azure Function using JavaScript - getToken Function
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
var adal = require('adal-node'); | |
const TENANT = "{tenant-name-here}.onmicrosoft.com"; | |
const CLIENT_ID = "{Application-id-here}"; | |
const CLIENT_SECRET = "{Application-key-here}"; | |
function getToken() { | |
return new Promise((resolve, reject) => { | |
const authContext = new adal.AuthenticationContext(`https://login.microsoftonline.com/${TENANT}`); | |
authContext.acquireTokenWithClientCredentials(GRAPH_URL, CLIENT_ID, CLIENT_SECRET, (err, tokenRes) => { | |
if (err) { reject(err); } | |
resolve(tokenRes.accessToken); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var adal = require('adal-node');
=>const adal = require('adal-node');
Seems like you are mixing ECMAScript's together.