-
Notifications
You must be signed in to change notification settings - Fork 84
Closed
Description
I am getting an error whenever my token expires and there is an attempt to auto-refresh the token. This is the function I am calling, with some information redacted for privacy purposes. The function takes a client that I instantiate with the httr2::oauth_client() function.
api_request_function <- function(client) {
httr2::request("[MY_API_URL]") |>
httr2::req_url_path_append("[PATH_ONE]") |>
httr2::req_url_path_append("[PATH_TWO]") |>
httr2::req_oauth_client_credentials(
client,
scope = paste(
"[SCOPE_ONE]",
"[SCOPE_TWO]"
),
token_params = list(
"[PARAM_ONE]" = "[XXX]",
"[PARAM_TWO]" = "[XXX]",
"[PARAM_THREE]" = "[XXX]"
)
) |>
httr2::req_retry(max_tries = 3) |>
httr2::req_perform() |>
httr2::resp_body_json()
}
The function works perfectly fine when the token hasn't expired, but once it expires I get the following error and traceback:
Error: $ operator is invalid for atomic vectors
11. is_string(url)
10. new_request(base_url)
9. request(client$token_url)
8. oauth_client_get_token(client, grant_type = "refresh_token", refresh_token = refresh_token, scope = scope, !!!token_params)
7. token_refresh(flow$params$client, token)
6. auth_oauth_sign(req)
5. httr2::req_perform(httr2::req_retry(req_oauth_client_mosaic(httr2::req_url_path_append(httr2::req_url_path_append(httr2::request("[MY_API_URL]"), "[PATH_ONE]"), "[PATH_TWO]"), client = client), max_tries = 3))
4. is_response(req)
3. check_response(resp)
2. httr2::resp_body_json(httr2::req_perform(httr2::req_retry(req_oauth_client_mosaic(httr2::req_url_path_append(httr2::req_url_path_append(httr2::request("[MY_API_URL]"), "[PATH_ONE]"), "[PATH_TWO]"), client = client), max_tries = 3)))
1. api_request_function(client)
After getting this error, if I try running the function again it works perfectly fine until the token expires again, and then I get the same error. It seems like there might be an issue with refreshing the token? I am using version 0.2.1 of the httr2 package. Happy to provide more information if needed!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels