Created
March 14, 2018 09:57
-
-
Save andrei-markeev/12f8e17a44957a04a2dc818ab22a5ea3 to your computer and use it in GitHub Desktop.
Azure Function get MS Graph access token
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
async function getMSGraphAccessToken() { | |
var body = { | |
grant_type: 'client_credentials', | |
client_id: process.env.AZURE_APP_ID, | |
client_secret: process.env.AZURE_APP_SECRET, | |
resource: 'https://graph.microsoft.com' | |
}; | |
var responseText = await request('https://login.windows.net/' + process.env.AZURE_TENANT_ID + '/oauth2/token', { method: 'POST', body, format: 'urlencoded' }); | |
var access_token = JSON.parse(responseText).access_token; | |
return access_token; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment