【发布时间】:2016-07-29 14:55:06
【问题描述】:
护照(Jared Hanson),
如何通过 openID 或 OAuth 使用 Paypal?
我正在使用 passport-paypal-oauth 策略 (https://github.com/jaredhanson/passport-paypal-oauth),
注意:我的路线以 localhost:4000/api/users 开头
我的贝宝端点:
var passport_paypal = require('../middlewares/passport-paypal');
router.get('/signin/paypal', passport_paypal.authenticate('paypal-signin', {
scope: 'openid profile email'}));
router.get('/signin/paypal/callback', function(req, res, next){
passport_paypal.authenticate('paypal-signin', function(err, user, info){
// Handle cases
//return res.status(xxx).json('..
});
我的贝宝策略:
var PaypalStrategy = require('passport-paypal-oauth').Strategy;
passport.use('paypal-signin', new PaypalStrategy({
clientID : "MY APP ID",
clientSecret : "MY APP SECRET",
callbackURL : "http://localhost:4000/api/users/signin/paypal/callback",
tokenURL : "https://api.sandbox.paypal.com/v1/oauth2/token",
authorizationURL : "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize"
}, function(token, refreshToken, profile, done) {
!!!!! Not called ...
// Get user profie
// Save in db or other handling
}));
问题:当我打电话给http://localhost:4000/api/users/signin/paypal时, 我在浏览器中得到以下答案:
[InternalOAuthError: failed to obtain access token]
name: 'InternalOAuthError',
message: 'failed to obtain access token',
oauthError:
{ statusCode: 400,
data: '{"error":"invalid_client","error_description":"Client credentials are missing"}' } }
并且永远不会调用function(token, refreshToken, profile, done) {。
怎么了?
【问题讨论】:
-
我同样的问题,我尝试使用passport-paypal,passport-paypal-openidconnect,但它不起作用..
-
不确定是否能解决您的问题,但 callbackUrl 应包含 localhost:4000
-
没有Molda,我的callbackURL已经包含localhost:4000:这是客户端凭据定义期间护照策略的问题。
标签: node.js paypal oauth passport.js