Comments (6)
I was able to auth but I had to first find the app installation id via find_app_installations()
and then call create_app_installation_access_token(installation_id)
. Only then can you set the access_token on the client and make calls-- using a JWT to auth as the Github App doesn't work, by itself. This should probably be documented somewhere in the auth section as going by the current example leads to 401s.
from octokit.rb.
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs
. You & others like you are the reason all of this works! So thank you & happy coding! 🚀
from octokit.rb.
Hey @auramix Thanks for reaching out and sorry for the trouble that you're running into.
So the pattern Authorization: token <my_access_token>
is a valid implementation when using PATs - have a look at the docs here on that.
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.
I've got another report of intermittent 401
s when using tokens in the .NET SDK here. It makes me wonder if the two are related. The implementation has been the same for some time now.
Would you happen to be able to tell me what type of token you're using - JWT, PAT, etc?
from octokit.rb.
Thanks, @nickfloyd .
I was using my Github App's client secret for the token. As I mentioned, this works when using the github api via curl and postman although it isn't the recommended way to auth. Octokit ruby docs state that authenticating a Github app should use JWT, but I wasn't able to get that to work for some reason, not with curl, postman, or the ruby client-- I get a 401, and unfortunately haven't been able to debug and find out why.
from octokit.rb.
@nickfloyd -- Wanted to ask for some advice on ways to debug auth with JWT for Github Apps using the Ruby client since that is the suggested way. Here is what I'm doing:
private_key = OpenSSL::PKey::RSA.new(private_pem)
# Generate the JWT
payload = {
# issued at time, 60 seconds in the past to allow for clock drift
iat: Time.now.to_i - 60,
# JWT expiration time (10 minute maximum)
exp: Time.now.to_i + (10 * 60),
# GitHub App's identifier
iss: <app_id_goes_here>
}
jwt = JWT.encode(payload, private_key, "RS256")
token = <token_value_goes_here>
client = Octokit::Client.new(:bearer_token => jwt)
repos = client.org_repos("my_org").select{ |repo| repo[:archived] == false}
I've also checked that I have the correct repository permissions set for my Github App. Not sure what's going on here.
from octokit.rb.
Hey @auramix,
Apologies for the delay on this one and thank you for hunting it down. We'll make a task to go through the docs on these auth methods to make sure no one else runs into the roadblocks that you did.
from octokit.rb.
Related Issues (20)
- [FEAT]: Support for Environment based Repository Secrets HOT 1
- [FEAT]: Add methods for app webhooks HOT 1
- [BUG]: Fetch a given reference uses the wrong API HOT 5
- [FEAT]: add missing endpoints HOT 2
- [DOCS]: README and yardocs refer to deleted method `#create_authorization` HOT 1
- [FEAT]: Refresh a user's access token with refresh token HOT 1
- Test issue HOT 1
- [FEAT]: Support Org Secrets HOT 1
- Get Projects by personal access token-Must have admin rights to Repository HOT 2
- [FEAT]: Provide response types with Sorbet HOT 1
- [BUG]: HTTP caching middleware returns cached responses to wrong users HOT 4
- [BUG]: `list_app_installation_repositories` does not return `rels` HOT 1
- [BUG]: Net::OpenTimeout (Faraday::ConnectionFailed) for request in threads HOT 1
- [FEAT]: timeline events are not supported? HOT 2
- How to get repository by its ID? HOT 2
- [FEAT]: Add Full Code Scanning Support HOT 1
- [DOCS]: How can I use octokit to manager new project HOT 1
- [DOCS]: Fix / update generation for the docs for Octokit.rb HOT 1
- [BUG]: `faraday-multipart` warning always printed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from octokit.rb.