嘗試使用護照的WordPress https://www.npmjs.org/package/passport-wordpress的node.js,護照,WordPress的:所需要的「REDIRECT_URI」參數缺少
護照WordPress允許您使用您的憑據登錄到node.js的應用創建一個演示在wordpress.com
我設立在developer.wordpress.com/apps我的WordPress應用:
OAuth Information Client ID <removed> Client Secret <removed> Redirect URL http://greendept.com/wp-pass/ Javascript Origins http://wp-node2.herokuapp.com Type Web Request token URL https://public-api.wordpress.com/oauth2/token Authorize URL https://public-api.wordpress.com/oauth2/authorize Authenticate URL https://public-api.wordpress.com/oauth2/authenticate
在我的Node.js應用:
var CLIENT_ID = <removed>;
var CLIENT_SECRET = <removed>;
passport.use(new WordpressStrategy({
clientID: CLIENT_ID,
clientSecret: CLIENT_SECRET
},
function(accessToken, refreshToken, profile, done) {
User.findOrCreate({ WordpressId: profile.id }, function (err, user) {
return done(err, user);
});
}
當我嘗試授權,它進入這個網址(如一條線,我已經分成兩這裏閱讀):
https://public-api.wordpress.com/oauth2/authorize ?
response_type=code&redirect_uri=&client_id= removed
我可以看到REDIRECT_URI中缺少的是URL,所以這並不奇怪,我得到這個錯誤:
Invalid request, please go back and try again.
Error Code: invalid_request
Error Message: The required "redirect_uri" parameter is missing.
不知道在哪裏或如何在我的代碼我應該提交REDIRECT_URI。
這工作!謝謝。一個小錯字:祕密行後需要逗號: clientSecret:'shhh-its-a-secret', – user1147171 2014-10-07 02:50:46