Skip to content
This repository has been archived by the owner on Oct 31, 2019. It is now read-only.

Commit

Permalink
#40 ENCODE the client secret to avoid occasional 401
Browse files Browse the repository at this point in the history
  • Loading branch information
Alanwe committed Jan 12, 2017
1 parent bea5a01 commit 8a9c28d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion R/AzureAuthenticate.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ azureAuthenticate <- function(azureActiveContext, tenantID, clientID, authKey, v

URLGT <- paste0("https://login.microsoftonline.com/", AtenantID, "/oauth2/token?api-version=1.0")

AauthKeyE <- URLencode(AauthKey, reserved = TRUE)

bodyGT <- paste0("grant_type=client_credentials&resource=https%3A%2F%2Fmanagement.azure.com%2F&client_id=",
AclientID, "&client_secret=", AauthKey)
AclientID, "&client_secret=", AauthKeyE)

r <- httr::POST(URLGT,
add_headers(
Expand Down
6 changes: 5 additions & 1 deletion R/AzureTemplate.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,16 @@ azureDeployTemplate <- function(azureActiveContext, deplname, templateURL,
r <- PUT(URL, add_headers(.headers = c(Host = "management.azure.com",
Authorization = AT, `Content-type` = "application/json")), body = bodyI,
verbosity)

rl <- content(r, "text", encoding = "UTF-8")
if (verbose == TRUE && status_code(r) != 200 && status_code(r) != 201 && status_code(r) !=
202) print (rl)

# print(paste(deplname,'Submitted'))
if (status_code(r) != 200 && status_code(r) != 201 && status_code(r) !=
202) {
stopWithAzureError(r)
}
rl <- content(r, "text", encoding = "UTF-8")
# print (rl)
df <- fromJSON(rl)
if (toupper(mode) == "SYNC") {
Expand Down

0 comments on commit 8a9c28d

Please sign in to comment.