Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL helpers, with auth #5

Open
ijlyttle opened this issue Jan 4, 2022 · 0 comments
Open

URL helpers, with auth #5

ijlyttle opened this issue Jan 4, 2022 · 0 comments

Comments

@ijlyttle
Copy link
Member

ijlyttle commented Jan 4, 2022

Next, we can make it a little easier to create requests, and to include auth:

# creates request using Box URL, adds auth
bx_request(resource, auth = NULL) # auth can be char or function, NULL means use pkg env

# takes request, adds auth
bx_req_auth(req, auth = NULL) # uses default auth

with this we could do:

library("httr")
library("cardboard")

bx_auth_use("personal")

request("https://api.box.com/2.0/users/me") %>%
  bx_auth() %>%
  req_perform() %>% 
  resp_body_json()

# more concise
bx_request("users/me") %>%
  req_perform() %>% 
  resp_body_json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant