Search code examples
rswaggertidyversehttr

api authorization header r httr


I am trying to access the Open Apparel Registry api using httr.

NB: It's free to sign up (need to login + get authentication code on profile page). But you can see the swagger api docs here: https://openapparel.org/api/docs/#!/facilities/facilities_list

Here is how you authorize on web version: enter image description here

oar_root_api <- "https://openapparel.org/api/facilities/"
oar_token <- XXX
oar_api_facilities_GET <- httr::GET(url = oar_root_api,
                                    add_headers(
                                                `Authorization` = oar_token),
                                    verbose()
                                    )

The code I receive back is 401 so something is wrong with my authorization, but I've tried so many ways. I can't figure out how to specify this correctly.


Solution

  • Sorry to hear you've been having difficulties. This additional documentation may help: https://docs.google.com/document/d/1ZKCN84Eu9WDAXUokojOw7Dcg5TAJw0vKnVk7RPrTPZ0/edit?usp=sharing

    We tend to find that users need to add the "Token" prefix (see page 3), which I appreciate isn't standard practice - this is something we intend to change!

    Let us know how you get on.

    • OAR