зеркало из https://github.com/Azure/AzureAuth.git
more bad token fixes
This commit is contained in:
Родитель
cf2cd75a91
Коммит
3316599e7c
|
@ -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)
|
||||
|
|
11
R/format.R
11
R/format.R
|
@ -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",
|
||||
|
|
Загрузка…
Ссылка в новой задаче