SonarSource / sonar-loc-count

GNU Lesser General Public License v3.0
37 stars 27 forks source link

Rate limiting on github.com #18

Closed yassinecc closed 1 year ago

yassinecc commented 1 year ago

curl -s -u github_pat_xxxx: https://api.github.com/repos/my_org/my_repo/branches
gives

{                                                                                                        
  "message": "API rate limit exceeded for $MY_IP. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",                               
  "documentation_url": "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"                                                                                                             
}

I had to change the curl to curl -s --header "Authorization: Bearer github_pat_xxxx" https://api.github.com/repos/my_org/my_repo/branches

Can the script use an authentication method with a high rate limit?

sylvain-combe-sonarsource commented 1 year ago

Hi @yassinecc thanks for your interest in the script. curl -u should be functionally equivalent to setting the authorization header yourself. And there seems to be a glitch there in the GH script. Can you try to update this line as follows curl -s -u $user:$connectionToken $BaseAPI/repos/$org/$Name/branches | jq -r '.[].name' | while read -r BrancheName ;

And let me know how it goes?

yassinecc commented 1 year ago

Hello @sylvain-combe-sonarsource

Yes it works fine :+1: Should I make a PR for it?