Github¶
Rate limits¶
-
Solution: Create a fine grained access token to make authenticated calls to the GitHub Rest API to circumvent the REST API rate limits
- No additional scope is needed
cli tool¶
https://cli.github.com/ https://cli.github.com/manual/
Setup:
Create personal access token (https://github.com/settings/tokens/new) with the following scopes:
- repo* (required)
- read:org (required)
- read:public_key
- read:repo_hook
- gist
- notifications
- read:user
- user:email
- write:discussion
- read:gpg_key
Usage:
API¶
https://developer.github.com/v3
Examples¶
Show all repos the token has access to in a organisation:
curl -s -H "Authorization: token $(gopass cad/www/github.com/dashboard-token)" \
"https://api.github.com/orgs/leapcode/repos" | jq '.[].name'
Show user which the particular token authenticated with:
curl -s -H "Authorization: token $(gopass cad/www/github.com/dashboard-token)" "https://api.github.com/user"
Fetch issues¶
curl -s -H 'Authorization: token 123' "https://api.github.com/pixelated/project-issues/issues\?page\=1\&per_page\=100"
Use 2-factor auth¶
Basic auth will fail
curl --netrc "https://api.github.com/pixelated/project-issues/issues\?page\=1\&per_page\=100"
{
"message": "Must specify two-factor authentication OTP code.",
"documentation_url": "https://developer.github.com/v3/auth#working-with-two-factor-authentication"
}
Generate 2fa code and then:
Download / embed images from git repos¶
https://stackoverflow.com/a/4605068
i.e.