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

jwt_token not accurately named #181

Open
aph3rson opened this issue Aug 14, 2024 · 0 comments
Open

jwt_token not accurately named #181

aph3rson opened this issue Aug 14, 2024 · 0 comments

Comments

@aph3rson
Copy link

In the constructor for a GhApi object, the jwt_token parameter appears to be used as a bearer token, whereas the token parameter uses an Authorization: token prefix:

ghapi/ghapi/core.py

Lines 96 to 101 in 4fe9459

if authenticate:
token = token or os.getenv('GITHUB_TOKEN', None)
jwt_token = jwt_token or os.getenv('GITHUB_JWT_TOKEN', None)
if jwt_token: self.headers['Authorization'] = 'Bearer ' + jwt_token
elif token: self.headers['Authorization'] = 'token ' + token
else: warn('Neither GITHUB_TOKEN nor GITHUB_JWT_TOKEN found: running as unauthenticated')

There are other types of bearer tokens apart from JWTs. In the app space, installation access tokens are also passed via a Bearer header, but are not JWTs. These look more like PATs, starting with ghs_.

I might recommend:

  • clarifying the documentation on different ways to authenticate to the GitHub API, or pointing at the appropriate GitHub docs.
  • rename the current jwt_token arg to something like bearer_token
  • raise a non-fatal warning when jwt_token is specified, asking developers to use the appropriately-named bearer_token arg.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant