我需要将下面的帖子请求转换为Rails Net::HTTP
请求。
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
我正在使用这个文档
您可以使用Rails Net :: HTTP类本身。尝试,
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
有关详细信息see