2015-06-13 42 views
1

我正尝试将用户重定向到我的应用中的Google授权页面。对于我的情况,我无法使用任何Google API模块。如何将查询参数添加到node.js/express.js res.redirect函数?

我知道我可以格式化我res.redirect()函数,例如: res.redirect('https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar.readonly&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A3000%2Fauth&client_id=690512789525-g8dbv0s1jo80u5hvevptqapeqokq7ees.apps.googleusercontent.com&hl=en&from_login=1&as=-6cc9a02870d13e22&authuser=0')

但我喜欢的东西更清洁,在那里我可以把我的查询参数中的对象。类似于:

res.redirect({uri: 'https://accounts.google.com/o/oauth2/auth, scope: 'https://............etc', response_type: 'code', etc }) 将每个查询参数都作为属性值对存储在我的对象中。

有关如何做到这一点的任何想法?

回答