I am using the following code to get an access token using AzureAuth package in R
library (AzureAuth) AuthToken <- get_azure_token("