【问题标题】:RAILS Quickbook oauth2 convert url to Net ::HTTP requestRAILS Quickbook oauth2 将 url 转换为 Net ::HTTP 请求
【发布时间】:2018-12-21 10:07:51
【问题描述】:

我需要将下面的 post 请求转换为 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

我正在使用此文档

https://developer.intuit.com/app/developer/qbpayments/docs/develop/authentication-and-authorization/oauth-2.0#exchange-code-for-refresh-and-access-tokens

【问题讨论】:

    标签: ruby-on-rails oauth-2.0 ruby-on-rails-5 quickbooks


    【解决方案1】:

    您可以为此目的使用 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多