Skip to content

Instantly share code, notes, and snippets.

@havenwood

havenwood/xco.rb Secret

Last active August 20, 2017 00:39
Show Gist options
  • Save havenwood/e516788b28a6e2f315017bfd35a7a237 to your computer and use it in GitHub Desktop.
Save havenwood/e516788b28a6e2f315017bfd35a7a237 to your computer and use it in GitHub Desktop.
Conversion of `curl -d 'grant_type=client_credentials&client_id=#{ api_key }&client_secret=#{ api_secret }' "https://api.gettyimages.com/oauth2/token"`
require 'net/http'
require 'uri'
uri = URI.parse 'https://api.gettyimages.com/oauth2/token'
req_options = {use_ssl: true}
request = Net::HTTP::Post.new uri
params = {grant_type: 'client_credentials',
client_id: ENV['API_KEY'],
client_secret: ENV['API_SECRET']}
request.body = URI.encode_www_form params
response = Net::HTTP.start uri.hostname, uri.port, req_options do |http|
http.request request
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment