github icon indicating copy to clipboard operation
github copied to clipboard

Allow passing a JWT as an authentication method

Open thomasin opened this issue 2 years ago • 1 comments

Hello (: I'm using this library and have added a couple of unsupported endpoints locally, that I am hoping to make a PR for soon. However, some of them require the request passes a JWT instead of an OAuth token.

This library, when you use OAuth authorisation, sets the Authorisation header as Authorisation: token {token}.
However there is a note in the GitHub API docs that states:

Note: In most cases, you can use Authorization: Bearer or Authorization: token to pass a token. However, if you are passing a JSON web token (JWT), you must use Authorization: Bearer.

So it looks like allowing users to pass JWTs could be as simple as changing that token to Bearer (which would also be backwards compatible and so not require a major library version bump). However, it might be more explicit and user friendly to add a new JWT option to the GitHub.Auth sum type.

Hope this is all clear! Happy to open any needed PRs

thomasin avatar Jan 05 '23 17:01 thomasin

FWIW, at a glance it looks like you define a wrapper type for a JWT and define your own instance of AuthMethod. A mild inconvenience. I agree this library should adopt a JWT case of AuthMethod, as in https://github.com/haskell-github/github/pull/497. But I don't think the current lack of support is a hard blocker.

frasertweedale avatar Nov 30 '23 04:11 frasertweedale