Question

/oauth2callback?code=4/SOMECODE.LOL-ISHERE

Hello there the above url is sent from an OAUTH request generated by the googleapis package in node.js.

I have tried so many routes but it never matches.

app.get('/oauth2callback?code=4/:token', routes.oauth);

app.get('/oauth2callback*/:token', routes.oauth);

app.get('/oauth2callback/:token', routes.oauth);

Any advice?

Was it helpful?

Solution

The only route that will match is

app.get('/oauth2callback', routes.oauth)

because /oauth2callback is the resource path. The rest of the URL string you've described is a querystring.

You can access the query parameters on the the req object that will be passed to routes.ouath. Yours will be available at req.params.code and will look like 4/SOMECODE.LOL-ISHERE

OTHER TIPS

could you test it with app.use or app.all instead please , as I can't find any documentation whether the request send by this package would actually be a get request! These options will at least allow you to rule out such occurrences where the request is not as expecte

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top