Skip to content

Instantly share code, notes, and snippets.

@enocom
Created February 4, 2014 07:42
Show Gist options
  • Save enocom/8799593 to your computer and use it in GitHub Desktop.
Save enocom/8799593 to your computer and use it in GitHub Desktop.
require "net/http"
require "uri"
require "json"
require "openssl"
require "yaml"
OAUTH_TOKEN = "some token goes here"
uri = URI.parse("https://api.github.com/users/enocom/repos")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
request["Accept"] = "application/json"
request["Authorization"] = "token #{OAUTH_TOKEN}"
response = http.request(request)
json_body = JSON.parse(response.body)
File.open("body_json", "w") { |f| f.write json_body.to_yaml }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment