最近在学着对接淘宝的API
在登录那里被被搞晕了,下面是淘宝的说明
http://open.taobao.com/doc/detail.htm?spm=0.0.0.0.sIg3jQ&id=118
我是使用Server-side flow方法来获取
(1) 通过用户授权获取授权码Code; (获取授权码 :https://oauth.taobao.com/authorize ;沙箱访问 https://oauth.tbsandbox.com/authorize )
//沙箱环境
protected string AppKey = "102223556992";
protected string AppSecret = "sand3xc00f28d1f022ae6343ed69f5d";
protected void Page_Load(object sender, EventArgs e)
{
string url = "https://oauth.tbsandbox.com/authorize"; //沙箱环境
//参数
taobao.Model.parameterCode model = new Model.parameterCode()
{
client_id = AppKey,
redirect_uri = "localhost:50138/OAuth.aspx",
response_type = "code",
state = "13",
view = "web"
};
url += ("?client_id=" + model.client_id + "&redirect_uri=" + model.redirect_uri + "&response_type=" + model.response_type + "&state=" + model.state + "&view=" + model.view);
Response.Redirect(url);
}
这个第一步我已经完成了,然后完成后淘宝自动呆着code回转到localhost:50138/OAuth.aspx这个页面,这个页面的CS代码如下第二步所释。
(2) 用上一步获取的Code和应用密钥(AppSecret)通过Https Post方式换取Token。 (获取访问令牌: https://oauth.taobao.com/token ; 沙箱访问 https://oauth.tbsandbox.com/token )
//沙箱环境
protected string AppKey = "102223556992";