Skip to content

Rewrite token in Ruby#17

Merged
pathawks merged 4 commits intomasterfrom
ruby-token
Jul 2, 2018
Merged

Rewrite token in Ruby#17
pathawks merged 4 commits intomasterfrom
ruby-token

Conversation

@pathawks
Copy link
Member

@pathawks pathawks commented Jun 18, 2018

This Ruby version is much less compact than the cURL script, but hopefully it is easier for Ruby devs to understand/debug.

/cc: #3

@pathawks pathawks changed the title Rewrite in Ruby Rewrite token in Ruby Jun 18, 2018
github/token Outdated
echo $TOKEN
jwt = File.expand_path("jwt", __dir__)

uri = URI("https://api.github.com/installations/#{ENV["INSTALLATION"]}/access_tokens")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps use ENV.fetch("INSTALLATION") since this is required?

github/token Outdated

uri = URI("https://api.github.com/installations/#{ENV["INSTALLATION"]}/access_tokens")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{`#{jwt}`}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps execute the jwt script elsewhere so we can check if it fails? Or write it in Ruby so we can use it as a library here?


http = Net::HTTP.new(uri.hostname, uri.port)
http.use_ssl = (uri.scheme == "https")
res = http.request(req)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would highly recommend using octokit's built-in method for this if you're going to be using Ruby.

@pathawks pathawks force-pushed the ruby-token branch 2 times, most recently from ef4f9e7 to aaa82ab Compare June 20, 2018 20:55
@pathawks pathawks merged commit 5980025 into master Jul 2, 2018
@pathawks pathawks deleted the ruby-token branch July 2, 2018 19:55
@pathawks pathawks mentioned this pull request Jul 2, 2018
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

Successfully merging this pull request may close these issues.

2 participants