Reputation: 11
I need to convert below post request into Rails Net::HTTP
request.
POST https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer HTTP/1.1
Accept: application/json
Authorization: Basic UTM0dVBvRDIwanp2OUdxNXE1dmlMemppcTlwM1d2NzRUdDNReGkwZVNTTDhFRWwxb0g6VEh0WEJlR3dheEtZSlVNaFhzeGxma1lXaFg3ZlFlRzFtN2szTFRwbw==
Content-Type: application/x-www-form-urlencoded
Host:oauth.platform.intuit.com
Body: grant_type=authorization_code&code=L3114709614564VSU8JSEiPkXx1xhV8D9mv4xbv6sZJycibMUI&redirect_uri=https://www.mydemoapp.com/oauth-redirect
I'm using this documentation
Upvotes: 1
Views: 257
Reputation: 828
You can use Rails Net::HTTP class itself for this purpose. Try,
require 'net/http'
url = URI.parse('https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer')
req = Net::HTTP::Post.new(url.to_s)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
puts res.body
For more details see
Upvotes: 1