Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving Github APi 403 error when I have not exceeded my rate limit

I'm scraping data off of Github via PyGithub. My issue is I receive this error during my scraping:

github.GithubException.GithubException: 403 {'documentation_url': 'https://developer.github.com/v3/#rate-limiting', 'message': 'API rate limit exceeded for XXXXX.'}

Upon curling the api I receive:

curl -i https://api.github.com/users/XXXXXX
HTTP/1.1 200 OK
Server: GitHub.com
Date: Thu, 14 Jul 2016 15:03:51 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 1301
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 52
X-RateLimit-Reset: 1468509718
Cache-Control: public, max-age=60, s-maxage=60
Vary: Accept
Last-Modified: Wed, 08 Jun 2016 13:29:08 GMT

note the Ratelimit labels:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 52
X-RateLimit-Reset: 1468509718

If I run my Python program again I will get another API rate limit exceeded message. I read the API documentation for github and as far as I can tell - I still have 52 requests left over. If I can provide anymore information to make this better let me know. Thank you.

Edit: To clarify I am using credentials to login into github.

ORGANIZATION = "ORG"
PERSONAL_ACCESS_TOKEN = "TOKEN"
g = Github(PERSONAL_ACCESS_TOKEN, per_page = 100)
github_organization = g.get_organization(ORGANIZATION)
like image 916
ChillMurray Avatar asked Oct 30 '22 00:10

ChillMurray


1 Answers

i had solved this problem with my previous work...here it is..

The 403 HTTP Status denotes a forbidden request, thus you have provided credentials that can't let you access some endpoints.

So you may need to provide a valid credentials (username / password) when creating the Github object:

#!/usr/bin/env python3
from github import Github

ACCESS_USERNAME = 'username'
ACCESS_PWD = "password"
client = Github(ACCESS_USERNAME, ACCESS_PWD, per_page=100)
user = client.get_user('ELLIOTTCABLE')
repo_list = [repo.name for repo in user.get_repos() if not repo.fork]
print(repo_list)

for j in repo_list:
    repo = user.get_repo(j)
    lang = repo.language
    print(j,':',lang)

Hope You'll Find it Useful.

like image 133
Farhan Ansari Avatar answered Nov 15 '22 05:11

Farhan Ansari