# NOT RUN {
# The private authenticated access only Cloud Run service
the_url <- "https://authenticated-cloudrun-ewjogewawq-ew.a.run.app/"
# creating the JWT and token
jwt <- cr_jwt_create(the_url)
token <- cr_jwt_token(jwt, the_url)
# call Cloud Run app using token with any httr verb
library(httr)
res <- cr_jwt_with_httr(
GET("https://authenticated-cloudrun-ewjogewawq-ew.a.run.app/hello"),
token
)
content(res)
# call Cloud Run app with curl - you can pass in a curl handle
library(curl)
h <- new_handle()
handle_setopt(h, customrequest = "PUT")
handle_setform(h, a = "1", b = "2")
h <- cr_jwt_with_curl(h, token = token)
r <- curl_fetch_memory("https://authenticated-cloudrun-ewjogewawq-ew.a.run.app/hello", h)
cat(rawToChar(r$content))
# use curls multi-asynch functions
many_urls <- paste0(
"https://authenticated-cloudrun-ewjogewawq-ew.a.run.app/hello",
paste0("?param="), 1:6
)
cr_jwt_async(many_urls, token = token)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab