I am trying to use redirect users to a Google Authorization page in my app. For my situation, I can't use any Google API modules.
I know I can format my res.redirect()
function as such:
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')
But I would prefer something cleaner, where I could keep my query parameters in an object. Something like:
res.redirect({
uri: 'https://accounts.google.com/o/oauth2/auth,
scope: 'https://............etc',
response_type: 'code',
[...etc...]
})
With each of my query params as an attribute-value pair in my object.
Any ideas on how to do that?
认为你需要这样的东西url.format(urlObj)
: https : url.format(urlObj)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.