<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>yeafee (yang)</title>
    <link>https://ruby-china.org/yeafee</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>淘宝开放平台基于 OAuth2.0 的登录验证授权 Net::HTTPBadResponse</title>
      <description>&lt;p&gt;基于 OAuth2.0 的登录验证授权方式介绍：&lt;a href="http://open.taobao.com/doc/detail.htm?id=118" rel="nofollow" target="_blank"&gt;http://open.taobao.com/doc/detail.htm?id=118&lt;/a&gt;；
(1) 通过用户授权获取授权码 Code； （获取授权码 :&lt;a href="https://oauth.taobao.com/authorize" rel="nofollow" target="_blank"&gt;https://oauth.taobao.com/authorize&lt;/a&gt; ）
(2) 用上一步获取的 Code 和应用密钥（AppSecret）通过 Https Post 方式换取 Token。 （获取访问令牌： &lt;a href="https://oauth.taobao.com/token" rel="nofollow" target="_blank"&gt;https://oauth.taobao.com/token&lt;/a&gt; ）
沙箱环境 访问 &lt;a href="https://oauth.tbsandbox.com/authorize" rel="nofollow" target="_blank"&gt;https://oauth.tbsandbox.com/authorize&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;我是在沙箱环境下，已经获取授权码，第二步报错了，&lt;/p&gt;

&lt;p&gt;params={"client_id"=&amp;gt;"appid",
        "client_secret"=&amp;gt;"sandboxsecret", 
        "grant_type"=&amp;gt;"authorization_code",
        "code"=&amp;gt;授权码，
        "redirect_uri"=&amp;gt;"&lt;a href="http://127.0.0.1:3000" rel="nofollow" target="_blank"&gt;http://127.0.0.1:3000&lt;/a&gt;"}
url= URI.parse('&lt;a href="https://oauth.tbsandbox.com/authorize" rel="nofollow" target="_blank"&gt;https://oauth.tbsandbox.com/authorize&lt;/a&gt;')
response = Net::HTTP.post_form(url,params)&lt;/p&gt;

&lt;p&gt;错误如下，
Net::HTTPBadResponse in HomeController#index
wrong status line: "&amp;lt;!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"&amp;gt;"&lt;/p&gt;

&lt;p&gt;了解的给指个路，谢谢；&lt;/p&gt;</description>
      <author>yeafee</author>
      <pubDate>Tue, 20 Nov 2012 14:38:29 +0800</pubDate>
      <link>https://ruby-china.org/topics/6933</link>
      <guid>https://ruby-china.org/topics/6933</guid>
    </item>
  </channel>
</rss>
