1
我是node.js的新手,請耐心等待。我正在嘗試在GET之後發出POST請求。 Idea一旦用戶點擊主頁,我想將該用戶重定向到salesforce並執行OAUth舞蹈。我正在使用expressJS和mikeal的請求。這是我到目前爲止的代碼ExpressJS/Request - GET後發出POST請求
server.get('/', function(req, res){
var client_id = "xxx";
var client_secret = "xxx";
var redirect_uri = "https://192.168.233.105:8000/callback";
var grant_type = "authorization_code";
var remotereq = request.post('https://na1.salesforce.com/services/oauth2/token').form(
{"client_id":client_id,
"client_secret":client_secret,
"redirect_uri":redirect_uri,
"grant_type":grant_type,
"immediate":'true'
}
);
//How do I get the expressJS res object to use the remotereq object?
});
當我打到主頁時,請求只是掛起。我想我必須以某種方式獲得expressJS響應對象,才能與mikeal/request對象進行良好的對話。我如何將兩者連接在一起?
如果你想節省一些麻煩,你可以看看[node-salesforce](https://github.com/stomita/node-salesforce#authorization-request)或[passport-forcedotcom](https ://github.com/joshbirk/passport-forcedotcom)。否則,我不完全確定你的意圖是什麼。您可以使用'remotereq.pipe(res)'將request.post的結果傳遞給響應,但是我不太明白這樣做的目的。 – robertklep 2013-05-09 16:52:09
@robertklep感謝關於現有工具的提示,我會檢查它們。我基本上想要做的是,只要用戶點擊主頁,就向POST終端發出POST請求。 – 2013-05-09 17:01:10
並將該請求的結果發送給客戶端?如果是這樣,管道應該足夠了。 – robertklep 2013-05-09 17:05:43