Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use authenticated requests on github api #29

Closed
gurneyalex opened this issue Jun 28, 2023 · 5 comments
Closed

use authenticated requests on github api #29

gurneyalex opened this issue Jun 28, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@gurneyalex
Copy link
Member

Is your feature request related to a problem?

When running oca port on "busy" projects a couple of time I get this error:

$ ~/oenv3/bin/oca-port --repo-name queue --fork work 14.0 15.0 queue_job
queue_job already exists on 15.0, checking PRs to port...
Traceback (most recent call last):
  File "/home/afayolle/oenv3/bin/oca-port", line 8, in <module>
    sys.exit(main())
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/__init__.py", line 140, in main
    PortAddonPullRequest(
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/port_addon_pr.py", line 96, in run
    branches_diff = BranchesDiff(
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/port_addon_pr.py", line 439, in __init__
    self.commits_diff = self.get_commits_diff()
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/port_addon_pr.py", line 547, in get_commits_diff
    pr = self._get_original_pr(commit)
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/port_addon_pr.py", line 641, in _get_original_pr
    raw_data = github.get_original_pr(
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/utils/github.py", line 31, in get_original_pr
    gh_commit_pulls = request(
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/utils/github.py", line 25, in request
    raise RuntimeError(response.text)
RuntimeError: {"message":"API rate limit exceeded for 88.170.64.58. (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"}

Describe the solution you'd like

I don't see an option to use authenticated requests, but it would be nice. And maybe some throttling could be used to avoid having the error?

@gurneyalex gurneyalex added the enhancement New feature or request label Jun 28, 2023
@sebalix
Copy link
Collaborator

sebalix commented Jul 3, 2023

Did you set your GH token?

$ export GITHUB_TOKEN=<token>

@sebalix
Copy link
Collaborator

sebalix commented Aug 5, 2024

The environment variable above should be mentioned in the documentation/CLI --help, so keeping this issue open.

@sbidoul
Copy link
Member

sbidoul commented Oct 12, 2024

What would be nice is to try and obtain the token using the gh client, a bit like this: https://github.com/OCA/maintainer-tools/blob/fbdc8945feabe1f6f3091c1b2d517b6c4160bc2b/tools/github_login.py#L25-L28.

@trisdoan
Copy link
Contributor

Hello @sbidoul , @sebalix , I implemented it in #63

@sebalix
Copy link
Collaborator

sebalix commented Dec 20, 2024

@sbidoul the PR done by @trisdoan allows to get the token from gh, thanks to both of you.

@sebalix sebalix closed this as completed Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants