express-oauth-server icon indicating copy to clipboard operation
express-oauth-server copied to clipboard

oauth not responding

Open ChicoFigueiredo opened this issue 6 years ago • 4 comments

I'm try generate oauth tokens with password grant but the server not responding my branch: https://github.com/ChicoFigueiredo/receita.digital/tree/001-criando-servidor-oauth2/server

Postman : Testes.postman_collection.json.zip

I'm using mongodb

ChicoFigueiredo avatar Jun 24 '18 22:06 ChicoFigueiredo

The same issue for me. ExpressOAuthServer.prototype.token Does not work.

nguyentuandat avatar Jul 25 '18 02:07 nguyentuandat

I just struck this one too. I'm still fairly new to Express, but try adding the oauth.authorize() call as a callback function to your route.

E.g.

app.post('/oauth2/authorize', (req, res, next) => {

   // Redirect to the login screen if the user is not authenticated
   if( !req.session.user ) {
      return res.redirect(`/login?redirect=${req.path}&${querystring.stringify(req.query)}`);
   }

   next();

}, app.oauth.authorize());

As oauth.authorize() essentially returns a middleware function, it's run in sequence after I handle whether the user is logged in or not.

moacode avatar Aug 13 '18 10:08 moacode

@ChicoFigueiredo - The link you supplied is missing.

@nguyentuandat can you supply some code?

@thejoshsmith - have you implemented the various model functions? What is exactly happening when you execute this route?

mjsalinger avatar Aug 13 '18 11:08 mjsalinger

@mjsalinger yes I implemented the model methods (using redis), however I found when using

return app.oauth.authorize();

in my authorize route, the server would just hang. I didn't spend too much time debugging as what I posted above did the trick.

moacode avatar Aug 14 '18 12:08 moacode