How to authenticate requests with HTTP.jl?

Suppose we want to get information from GitHub API for various users:

using HTTP
for user in users
  resp = HTTP.get("https://api.github.com/users/$user")
end

The code fails for a large number of users due to the reduced rate limits for unauthenticated requests. Can you please explain how one can authenticate these requests with HTTP.jl? I have my GitHub authentication token set and working with GitHub.jl.

GitHub can authenticate you using a personal access token. Once you generate the token, you can just add ?access_token=<YOUR_TOKEN> to the end of the URL and it should work. At least this is what worked for me in PackageTracker.jl.

1 Like

I’ve done something similar in a project - you’re better off interacting with GitHub through GitHub.jl
https://github.com/JuliaWeb/GitHub.jl

It takes a config where you pass your token and it handles authentication for you.

@essenciary, I used GitHub.jl at the time I asked the question:

The notebook is part of our JuliaGraphTutorials repository: Jupyter Notebook Viewer

Returning to the original post, how would one do this in general? Specifically I’m trying to connect to Companies House (https://developer.companieshouse.gov.uk/api/docs/index/gettingStarted/apikey_authorisation.html) and prepending my key and flagging basic_authorization doesn’t work