邮差oauth2与nodejs

时间:2017-09-22 10:32:48

标签: node.js oauth-2.0 postman

我想测试邮递员中的oauth2(nodejs)。

所以,我做了这条路:

router.get('/authorise', (req, res, next) => {
    console.log('in authorise');

});
邮递员,我设置了这个Url(指向我的路线):

enter image description here

这是工作。它到达这条路线。但我无法找到如何关闭此窗口并获取令牌?

响应应该是什么样的?

我在网上到处搜索,但找不到任何相关信息。

我试过这个但仍然没有工作:

router.get('/authorise', (req, res, next) => {
        console.log('in authorise');
        res.writeHead(302, { 
          Location: 'https://www.getpostman.com/oauth2/callback?access_token=8ba64c1fbe8d4c3a892e432425842adde38fbb0e&response_type=code' 
        });
        res.end();
    });

2 个答案:

答案 0 :(得分:0)

您需要从客户端而不是从Node应用程序打开窗口,当您从Node接收响应时,您可以关闭窗口。

答案 1 :(得分:0)

我找到了!

只需要像这样返回AUTHORIZATION_CODE:

Access Token Url

然后继续this.router.config.forEach(route => {