This commit is contained in:
Hong Ooi 2019-10-24 13:55:40 +08:00
Родитель cf2cd75a91
Коммит 3316599e7c
2 изменённых файлов: 11 добавлений и 4 удалений

Просмотреть файл

@ -166,10 +166,10 @@ private=list(
# v2.0 endpoint doesn't provide an expires_on field, set it here
if(is.null(self$credentials$expires_on))
{
expiry <- try(as.character(decode_jwt(self$credentials$access_token)$payload$exp))
expiry <- try(as.character(decode_jwt(self$credentials$access_token)$payload$exp), silent=TRUE)
if(inherits(expiry, "try-error"))
{
expiry <- try(as.character(decode_jwt(self$credentials$id_token)$payload$exp))
expiry <- try(as.character(decode_jwt(self$credentials$id_token)$payload$exp), silent=TRUE)
if(inherits(expiry, "try-error"))
stop("Bad access token, expiry date not found (do you have a valid tenant?)", call.=FALSE)
warning("Possibly bad access token (do you have a valid tenant?)", call.=FALSE)

Просмотреть файл

@ -24,8 +24,15 @@ format_auth_header <- function(token)
tenant <- token$tenant
if(tenant == "common")
{
token_obj <- decode_jwt(token$credentials$access_token)
tenant <- paste0(tenant, " / ", token_obj$payload$tid)
token_obj <- try(decode_jwt(token), silent=TRUE)
if(inherits(token_obj, "try-error"))
{
token_obj <- try(decode_jwt(token, "id"), silent=TRUE)
if(inherits(token_obj, "try-error"))
tenant <- "NA"
else tenant <- paste0(tenant, " / ", token_obj$payload$tid)
}
else tenant <- paste0(tenant, " / ", token_obj$payload$tid)
}
paste0("Azure Active Directory ", version, " token for ", res, "\n",