2015-06-13 46 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 }) 將每個查詢參數都作爲屬性值對存儲在我的對象中。

有關如何做到這一點的任何想法?

回答