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

Setting GITHUB_TOKEN to new style GH tokens fails with 403 Client Error #63

Closed
karthiknadig opened this issue Sep 20, 2021 · 1 comment · Fixed by #73
Closed

Setting GITHUB_TOKEN to new style GH tokens fails with 403 Client Error #63

karthiknadig opened this issue Sep 20, 2021 · 1 comment · Fixed by #73
Labels

Comments

@karthiknadig
Copy link

set GITHUB_TOKEN to the new tokens that github produces which start with ghp_.

Traceback (most recent call last):
  File "C:\all_pys\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\all_pys\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\GIT\release\pvsc\.venv\Scripts\githubrelease.exe\__main__.py", line 7, in <module>
  File "c:\git\release\pvsc\.venv\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\git\release\pvsc\.venv\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\git\release\pvsc\.venv\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\git\release\pvsc\.venv\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\git\release\pvsc\.venv\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\git\release\pvsc\.venv\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\git\release\pvsc\.venv\lib\site-packages\click\decorators.py", line 33, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "c:\git\release\pvsc\.venv\lib\site-packages\github_release.py", line 437, in cli_release_create
    gh_release_create(*args, **kwargs)
  File "c:\git\release\pvsc\.venv\lib\site-packages\github_release.py", line 116, in with_check_for_credentials
    return func(*args, **kwargs)
  File "c:\git\release\pvsc\.venv\lib\site-packages\github_release.py", line 444, in gh_release_create
    if get_release(repo_name, tag_name) is not None:
  File "c:\git\release\pvsc\.venv\lib\site-packages\github_release.py", line 259, in get_release
    releases = get_releases(repo_name)
  File "c:\git\release\pvsc\.venv\lib\site-packages\github_release.py", line 249, in get_releases
    _recursive_gh_get(
  File "c:\git\release\pvsc\.venv\lib\site-packages\github_release.py", line 155, in _recursive_gh_get
    response.raise_for_status()
  File "c:\git\release\pvsc\.venv\lib\site-packages\requests\models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.github.com/repos

Same command works with old style GH tokens. GH is asking repos to upgrade to new style tokens.

@jcfr jcfr added the bug label Dec 22, 2021
@jcfr
Copy link
Collaborator

jcfr commented Dec 22, 2021

Since the basic authentication is not supported anymore, the authentication should be updated to work with new style token by setting header like Authorization: token ghp_123...456

This means the following code should be updated:

https://github.com/j0057/github-release/blob/067d7f1f557e16c4db57696d30732d566e314a45/github_release.py#L74-L78

If a token doesn't start with ghp_, an error should be reported suggesting the user to create a new style token

For reference, see https://docs.github.com/en/rest/overview/troubleshooting#basic-authentication-errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants