2014-03-19 61 views
0

我一直在試圖使用passport-oauth2模塊來使用Log In With Paypal服務。在這一點上,我只使用沙箱,而不是生產(還)。「使用PayPal登錄」失敗,連接重置?

我成功使用passport-google-oauthpassport-amazon通過oauth2對每個服務進行身份驗證。鑑於此,我很困惑我在做什麼錯誤的貝寶。

隨着貝寶,我無法讓沙箱工作。我得到一個需要憑據的登錄屏幕,但輸入後我每次都會收到連接重置錯誤。我試圖從所有PayPal會話中註銷,關閉瀏覽器等。儘管我的客戶端擺弄,我從來沒有從PayPal回到我的回調。

所以...代碼!

我有很大的發展配置對象:

"paypal" : { 
    "clientID": "copied from the developer My REST Apps test credentials", 
    "clientSecret" : "more copied test credentials", 
    "callbackURL" : "https://localhost/auth/paypal/cb", 
    "authorizationURL": "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize", 
    "tokenURL": "https://api.sandbox.paypal.com/v1/identity/openidconnect/tokenservice" 
} 

而且我有一個小圖書館,這是否:

var PayPalStrategy = require('paypal-oauth2').Strategy; 
exports.paypalStrategy = function (conf) { 
    // 'conf' is the configuration from the first code block 
    return new PaypalStrategy({ 
      clientID: conf.clientID, 
      clientSecret: conf.clientSecret, 
      callbackURL: conf.callbackURL, 
      authorizationURL : conf.authorizationURL, 
      tokenURL: conf.tokenURL 
     }, 
     function (accessToken, refreshToken, profile, done) { 
      // we never get here because our connection is reset.   
     }); 
}; 

我的路線很簡單:

app.get('/auth/paypal', 
    passport.authenticate('oauth2', {scope: 'profile'}), 
    function (req, res) {} 
); 

app.get('/auth/paypal/cb', 
    passport.authenticate('oauth2', { failureRedirect: '/login' }), 
    function (req, res) { 
     res.redirect('/profile'); 
    }); 

我猜測是我(a)弄錯端點或(b)我錯過了測試accoun的某個步驟t貝寶開發網站上的配置。可悲的是,我似乎無法找到我需要的文檔。任何幫助或指導表示讚賞。

+0

你打開了必要的端口上收到的請求的客戶端?我會在接下來的幾天嘗試這個..將讓你知道,如果我得到它..我發現一個有用的git回購https://github.com/jaredhanson/passport-paypal/tree/master/examples/signon –

+0

你在說哪些端口?另外,passport-paypal模塊使用OpenID而不是OAuth ...並且[passport-paypal-oauth](https://github.com/jaredhanson/passport-paypal-oauth)模塊有一些問題妨礙了它的工作。這些是我直接使用OAuth模塊而不是爲paypal編寫的原因。 –

+0

噢好吧..我只是意味着打開防火牆的端口上的傳入連接,你的應用程序正在運行..quite basic ..但我沒有這樣做,當我嘗試其他(expresscheckout),然後連接會重置.. –

回答

0

礦工與以下內容:

1)清除瀏覽器緩存和歷史記錄。

2)刪除cookies。

然後再試一次。

+0

試過!作爲修復失敗。我嘗試重置Chrome,甚至打開了其他永不使用的瀏覽器。其他地方我一定有什麼問題。如果我弄清楚(我把它放在ToDo列表中),我會回來更新後代。 :( –

0

幾個小時後,我用護照掏空,結果我轉而使用node-palpal-sdk代替。我認爲令人困惑的是paypals oauth流量如何在端點URL上討論openid。以下是我得到它的工作的要點,向前伸直你把碎片後一起:

https://gist.github.com/jkresner/8a581e50dcac58edbd10