How to authenticate requests with HTTP.jl?

question
web

#1

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.


#2

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.


#3

I’ve done something similar in a project - you’re better off interacting with GitHub through GitHub.jl

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


#4

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

The notebook is part of our JuliaGraphTutorials repository: http://nbviewer.jupyter.org/github/JuliaGraphs/JuliaGraphsTutorials/blob/master/DAG-Julia-Pkgs.ipynb