Skip to content

Instantly share code, notes, and snippets.

@roccogalluzzo
Created July 3, 2014 15:52
Show Gist options
  • Save roccogalluzzo/32ddc56016c0f768b716 to your computer and use it in GitHub Desktop.
Save roccogalluzzo/32ddc56016c0f768b716 to your computer and use it in GitHub Desktop.
body = {
grant_type: 'authorization_code',
client_id: Rails.application.secrets[provider]['client_id'],
client_secret: Rails.application.secrets[provider]['client_secret'],
redirect_uri: integration_callback_url(provider),
code: params[:code]
}.to_query
uri = URI.parse('https://api.createsend.com/oauth/token')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri)
request.body = body
ActiveSupport::JSON.decode(http.request(request).body)['access_token']
# returns error 400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment