You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If so, I want to discuss the best way for implementation.
In my code I used trait GithubAuth with method def getAuthHeader():String. GithubClient taken instance of GithubAuth and call this function for token. In case of PAT it's return token from constructor, in case of private key it's looks like:
You're right we don't support github apps authorization.
However, I'm not sure about the best way to go about it as we don't want to handle jwt tokens directly in the library for example.
Agreed, maybe we can make GithubClient to accept instance of GithubAuth, so the user can use by default GithubPatAuth, in other cases they need to define own class.
But if it's part of Github Auth flow user will do same code over and over.
maybe we can make GithubClient to accept instance of GithubAuth, so the user can use by default GithubPatAuth, in other cases they need to define own class.
Hello - I'm interested about the status of this issue
We have a standalone service in our infrastructure that requires broad access to GH's REST api and the repositories under our organisation (DHL-Parcel) - preferably using the github4s library and authorise not via a personal access token - but either via JWT tokens or - as requested in this issue - via GH Apps authorisation.
We did try the new AccessToken feature to get this working but weren't able to. The main issue seems to be the Authorisation: token header being hardcoded in the library, but we might not understand the way the new features was intended to be used. In that case an example would help us.
If authorisation via JWT or GH App tokens is currently not possible we would able to spend some time on getting this to work with github4s provided that we get some help and pointers on how the preferred integration should look like in the API.
In that way, you can implement your algebra for generating auth headers, having complete control. Let me know your thoughts. The docs need to be updated accordingly.
Activity
BenFradet commentedon Sep 23, 2020
You're right we don't support github apps authorization.
However, I'm not sure about the best way to go about it as we don't want to handle jwt tokens directly in the library for example.
loonydev commentedon Sep 23, 2020
Agreed, maybe we can make
GithubClientto accept instance ofGithubAuth, so the user can use by defaultGithubPatAuth, in other cases they need to define own class.But if it's part of Github Auth flow user will do same code over and over.
loonydev commentedon Sep 28, 2020
So, do you have any suggestions how to implement it?
I can do that, by I need to be sure that I don't waste a time.
BenFradet commentedon Sep 29, 2020
I'm 👍 on that
loonydev commentedon Sep 29, 2020
But as I mention before, users will do same code over and over and not in the best way. It's like give them domain and say, use own http sender.
BenFradet commentedon Oct 1, 2020
We can add that code as documentation, it doesn't seem to me like the usage will be so huge that it would need to be part of the library.
loonydev commentedon Oct 1, 2020
Okay, next week I'm going to prepare this changes and will discuss it with real example.
kusaeva commentedon Nov 5, 2020
@loonydev Hi! Are you still planning to make a PR with this changes?
loonydev commentedon Nov 9, 2020
Morning @kusaeva, not yet, it's in plan, but not in a near future. If you have a time to make it, it would be great.
nmcb commentedon May 23, 2023
Hello - I'm interested about the status of this issue
We have a standalone service in our infrastructure that requires broad access to GH's REST api and the repositories under our organisation (DHL-Parcel) - preferably using the github4s library and authorise not via a personal access token - but either via JWT tokens or - as requested in this issue - via GH Apps authorisation.
We did try the new
AccessTokenfeature to get this working but weren't able to. The main issue seems to be theAuthorisation: tokenheader being hardcoded in the library, but we might not understand the way the new features was intended to be used. In that case an example would help us.If authorisation via JWT or GH App tokens is currently not possible we would able to spend some time on getting this to work with github4s provided that we get some help and pointers on how the preferred integration should look like in the API.
Thanks in advance :)
fedefernandez commentedon May 31, 2023
Hi @nmcb, thanks for your interest.
This is how it's currently built.
We have an algebra that allows generating tokens:
github4s/github4s/shared/src/main/scala/github4s/algebras/AccessToken.scala
Lines 31 to 34 in 9c18225
This algebra has a single implementation called
StaticAccessToken. You pass a token, and it returns as a pure value.github4s/github4s/shared/src/main/scala/github4s/interpreters/StaticAccessToken.scala
Lines 25 to 29 in 9c18225
When you create a new
Github4sclient, it's creates an instance of that algebra to use it internally:github4s/github4s/shared/src/main/scala/github4s/Github.scala
Line 53 in 9c18225
This is then used to create the internal
GithubAPIv3algebra:github4s/github4s/shared/src/main/scala/github4s/Github.scala
Line 31 in 9c18225
That, in a similar way, pass it to the internal
HTTPClientalgebra:github4s/github4s/shared/src/main/scala/github4s/modules/GithubAPIs.scala
Line 32 in 9c18225
The
HTTPClientuses thewithAccessTokento get the token and pass it to theRequestBuildergithub4s/github4s/shared/src/main/scala/github4s/http/HttpClient.scala
Lines 65 to 69 in 9c18225
The
RequestBuilderstores the token in aauthHeadermap, where the key isAuthorization, and the value iss"token $token".github4s/github4s/shared/src/main/scala/github4s/http/RequestBuilder.scala
Lines 44 to 48 in 9c18225
This is mapped to a
Header.Rawgithub4s/github4s/shared/src/main/scala/github4s/http/Http4sSyntax.scala
Line 50 in 9c18225
Potential solution
@loonydev's approach looks good, so I've created a draft with a potential solution:
In that way, you can implement your algebra for generating auth headers, having complete control. Let me know your thoughts. The docs need to be updated accordingly.
nmcb commentedon May 31, 2023
thanks @fedefernandez! we'll give it a try.
cc @thijsnissen