Skip to content

Instantly share code, notes, and snippets.

@jeffreyiacono
Created November 11, 2012 22:18
Show Gist options
  • Select an option

  • Save jeffreyiacono/4056476 to your computer and use it in GitHub Desktop.

Select an option

Save jeffreyiacono/4056476 to your computer and use it in GitHub Desktop.
Get github information for a user
require 'net/http'
require 'uri'
require 'io/console'
puts "Enter in a github username:"
gh_username = gets.chomp
puts "Enter in the github user password (hidden):"
gh_password = STDIN.noecho(&:gets).chomp
uri = URI.parse('https://api.github.com/user')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri.request_uri)
req.basic_auth(gh_username, gh_password)
r = http.request(req)
puts r.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment