|
8 | 8 | #' @keywords internal |
9 | 9 | #' @noRd |
10 | 10 | access_token <- function(config, token_str) { |
11 | | - UseMethod("access_token") |
12 | | -} |
13 | | - |
14 | | -#' @keywords internal |
15 | | -#' @noRd |
16 | | -access_token.google_config <- function(config, token_str) { |
17 | | - token_data <- decode_token(config, token_str) |
18 | | - structure( |
19 | | - list( |
20 | | - access_token = token_str, |
21 | | - exp = lubridate::as_datetime(token_data$exp), |
22 | | - iat = lubridate::as_datetime(token_data$iat), |
23 | | - token_data = token_data |
24 | | - ), |
25 | | - class = c("google_token", "access_token") |
26 | | - ) |
27 | | -} |
28 | | - |
29 | | -#' @keywords internal |
30 | | -#' @noRd |
31 | | -access_token.entra_id_config <- function(config, token_str) { |
32 | | - token_data <- decode_token(config, token_str) |
33 | | - structure( |
34 | | - list( |
35 | | - access_token = token_str, |
36 | | - exp = lubridate::as_datetime(token_data$exp), |
37 | | - iat = lubridate::as_datetime(token_data$iat), |
38 | | - token_data = token_data |
39 | | - ), |
40 | | - class = c("entra_id_token", "access_token") |
41 | | - ) |
42 | | -} |
43 | | - |
44 | | -#' @keywords internal |
45 | | -#' @noRd |
46 | | -access_token.auth0_config <- function(config, token_str) { |
47 | | - token_data <- decode_token(config, token_str) |
48 | | - structure( |
49 | | - list( |
50 | | - access_token = token_str, |
51 | | - exp = lubridate::as_datetime(token_data$exp), |
52 | | - iat = lubridate::as_datetime(token_data$iat), |
53 | | - token_data = token_data |
54 | | - ), |
55 | | - class = c("auth0_token", "access_token") |
56 | | - ) |
| 11 | + if (length(token_str) == 0) { |
| 12 | + return(error("No access_token provided")) |
| 13 | + } |
| 14 | + config$decode_token(token_str) |
57 | 15 | } |
58 | 16 |
|
59 | 17 | #' @title Print an access token |
@@ -112,8 +70,8 @@ is_expired <- function(token) { |
112 | 70 | #' @return A string containing the Authorization header |
113 | 71 | #' @keywords internal |
114 | 72 | #' @noRd |
115 | | -get_bearer <- function(token) { |
116 | | - paste0("Bearer ", token$access_token) |
| 73 | +add_bearer <- function(token) { |
| 74 | + paste0("Bearer ", token) |
117 | 75 | } |
118 | 76 |
|
119 | 77 | #' @title Get the access token string |
@@ -149,15 +107,3 @@ expires_in <- function(token) { |
149 | 107 | expires_at <- function(token) { |
150 | 108 | token$exp |
151 | 109 | } |
152 | | - |
153 | | -#' @title Get the issued at time of an access token |
154 | | -#' @description Gets the issued at time of an access token |
155 | | -#' |
156 | | -#' @param token An access_token object |
157 | | -#' @param field The field to get from the token |
158 | | -#' |
159 | | -#' @return A POSIXct object containing the date and time the token was issued |
160 | | -#' @export |
161 | | -get_token_field <- function(token, field) { |
162 | | - token$token_data[[field]] |
163 | | -} |
0 commit comments