I'm trying to make a GitHub client/repo downloader. Everything's going well so far, except that I seem to hit the GitHub rate limit. If I authorise, I can increase the rate limit from 60 to 5000, however I can't seem to figure out how to do that.
I've tried:
- Sending a GET request like
https://username:password@api.github.com/rate_limit
- As well as sending a POST request to their api website with a Base64'd version of my password and username (With the "Basic " prefix), the http.post returns nil
EG: I tried using my program to download Twitter Bootstrap. Before it had even finished finding all of the files, it hit the rate limit.
The program makes a request for every folder it finds in the repo
EDIT: Twbs/Bootstrap is an inappropriate repo (I really shouldn't use this as an example). Still, authentication methods would be nice
If authentication cannot be done, is there any way I can make my code use less api requests?
Note: jsonParser.lua converts the json from the API to a Lua table, and downloader.lua takes a table and actually downloads the files (Although this never happens with twbs/bootstrap as there are too many folders)
If it helps, jsonParser and downloader can be found here: https://github.com/C...CraftedCart/api
EDIT: JsonParser & Downloader has been relocated to https://github.com/CraftedCart/CC-Common/tree/master/api
Spoiler
repoName = "GitByte"
json = (loadfile "CraftedCart/api/jsonParser.lua")()
local files = {}
local dirs = {}
local function getDir(path)
web = http.get("https://api.github.com/repos/twbs/bootstrap/contents" .. path)
data = json:decode(web.readAll())
for k, v in pairs(data) do
if v["type"] == "dir" then
table.insert(dirs, v["path"])
print("Found Dir: " .. v["path"]) --TESTING
getDir("/" .. v["path"])
elseif v["type"] == "file" then
table.insert(files, {v["name"], v["download_url"], "Downloads/" .. repoName .. "/" .. v["path"]})
print("Found File: " .. v["path"]) --TESTING
end
end
end
getDir("")
for k, v in pairs(dirs) do
fs.makeDir(v)
end
os.loadAPI("CraftedCart/api/downloader.lua")
downloader = _G["downloader.lua"]
downloader.getAndInstall(files, 4)