Skip to content

Instantly share code, notes, and snippets.

@DiogoAndre
Created May 11, 2012 18:17
Show Gist options
  • Save DiogoAndre/2661478 to your computer and use it in GitHub Desktop.
Save DiogoAndre/2661478 to your computer and use it in GitHub Desktop.
Authenticated API call to the GitHub Users v3 API in Ruby
require 'net/http'
uri = URI('https://api.github.com/user')
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
request = Net::HTTP::Get.new uri.request_uri
request.basic_auth 'username', 'password'
response = http.request request
puts response.body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment