ammmir / node-oauth2-provider

A simple customizable OAuth 2.0 provider (server) for node.js.
MIT License
628 stars 161 forks source link

code/access_token query or body #33

Open bmatusiak opened 11 years ago

bmatusiak commented 11 years ago

can you add/change this to your lovely little module

    } else if(req.method == 'POST' && self.options.access_token_uri == uri) {
      var     client_id = req.body.client_id || req.query.client_id,
          client_secret = req.body.client_secret || req.query.client_secret,
           redirect_uri = req.body.redirect_uri || req.query.redirect_uri,
                   code = req.body.code || req.query.code;

im using everyauth as a client to oauth2

in the code it send via query not body... adding the || will fix issue

https://github.com/bnoguchi/everyauth/blob/master/lib/modules/oauth2.js#L186

this is exactly how it is sending code to retrieve access_token

also it my be nice to do this in "login" middleware function

 if(req.query['access_token'] || req.body['access_token']) {
      atok = req.query['access_token'] || req.body['access_token'];
    } else if((req.headers['authorization'] || '').indexOf('Bearer ') == 0) {
      atok = req.headers['authorization'].replace('Bearer', '').trim();
    } else {
      return next();
    }