【问题标题】:passport.js auth0 strategy Cross rigin request errorpassport.js auth0 策略跨域请求错误
【发布时间】:2014-10-17 23:14:07
【问题描述】:

我正在尝试在我的网络应用中使用 auth0 进行社交验证

我这样配置应用程序

auth0 : {
  domain : "mydomain",
  clientID : "myid",
  clientSecret: "mysecret",
  callbackURL: "/callback"
},

我使用 http get 从 Angular 控制器请求登录到节点后端,例如

  app.get('/auth/:connection', function(req, res, next) {

    passport.authenticate('auth0', {connection: req.params.connection}, function(err, user, info) {

    }) (req, res, next);
  });

我会像 auth/facebook 一样从 Angular 客户端控制器调用 facebook 登录。

回调路由是这样配置的

app.get('/callback', passport.authenticate('auth0', { failureRedirect: '#!/authServiceImpl/login' }), 
    function(req, res) {
      console.log('auth0 callback');
      console.log(req.user);
    }
  );

每次我收到跨源请求错误。 我做错了什么?

【问题讨论】:

    标签: angularjs node.js passport.js passport-facebook auth0


    【解决方案1】:

    我使用 http get 从 Angular 控制器请求登录到节点后端,例如

    您无法通过 XHR 执行 OAuth。而不是做$http.get('/auth/whatever') 你需要做window.location.pathname = '/auth/whatever'window.open('/auth/whatever')

    【讨论】:

      猜你喜欢
      • 2015-09-07
      • 1970-01-01
      • 2010-11-23
      • 2019-01-09
      • 2018-10-28
      • 2018-01-03
      • 2011-02-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多