MEANアプリケーションでAmazon Passportを認証しようとしていますが、クロスオリジンエラーが発生しています。私のアプリケーションは、このように設定されています平均積上げAmazon Passport Auth
ビュー:
<a id="LoginWithAmazon" ng-click="vm.auth()">
<img class="responsive-img amazon-button"/>
</a>
コントローラー:
vm.auth = function() {
Auth.login()
.then(function() {
$location.path('/');
})
.catch(function (err) {
vm.error = err;
});
}
サービス:
vm.login = function() {
var deferred = $q.defer();
$http.post('/auth/amazon')
.then(function (res) {
console.log('SUCCESS! ', res);
deferred.resolve();
})
.catch(function (err) {
console.log('ERR: ', err);
deferred.reject(err.data);
});
return deferred.promise;
};
そして、私のエクスプレス/ NodeJS文脈で
...パスポートはconfですこのようigured:
passport.use(new AmazonStrategy({
clientID: config.amazon.clientID,
clientSecret: config.amazon.clientSecret,
callbackURL: "http://localhost:9000/test"
},
function(accessToken, refreshToken, profile, done) {
console.log('SUCCESS AUTH: ', profile);
process.nextTick(function() {
return done(null,profile);
});
});
}
));
エクスプレスルート:
router.post('/auth/amazon', function (req, res, next) {
passport.authenticate('amazon', function (err, user, info) {
console.log('Err? ', err);
console.log('User: ', user);
})(req, res, next);
});
私が試した<a href="{{amazonUrl}} target="_blank">Login with Amazon</a>
を使用するが、同様に無駄に。私はアマゾンの設定でログイン時にhttp://localhost:9000
をホワイトリストに入れました。どんな助けでも大歓迎です。