Skip to content

Instantly share code, notes, and snippets.

@ramnov
Created August 5, 2017 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramnov/cd00b19b6a94373e77ba2c7269a40995 to your computer and use it in GitHub Desktop.
Save ramnov/cd00b19b6a94373e77ba2c7269a40995 to your computer and use it in GitHub Desktop.
R script to obtain Azure Active Directory Token
library(httr)
library(jsonlite)
library(curl)
h <- new_handle()
handle_setform(h,
"grant_type"="client_credentials",
"resource"="https://management.core.windows.net/",
"client_id"="<CLIENT ID>",
"client_secret"="<CLIENT SECRET>"
)
req <- curl_fetch_memory("https://login.windows.net/<TENANT ID>/oauth2/token", handle = h)
res <- fromJSON(rawToChar(req$content))
res$access_token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment