Azard / egg-oauth2-server

:star2: OAuth2 server plugin for egg.js based on node-oauth2-server
MIT License
178 stars 45 forks source link

Missing parameter: `grant_type` #41

Closed yxz0248 closed 5 years ago

yxz0248 commented 5 years ago

I have try egg-auth2-server as shown in test. But I got the error message : "Missing parameter: grant_type" with my request as follows:

request(${host}/user/token, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', Authorization: 'Basic bXlfYXBwOm15X3NlY3JldA==', }, data: { grant_type: 'password', username: 'egg-oauth2-server', password: 'azard', }, });

'oauth.js' and 'config.default.js' are the same as shown in test dir. Wish to get some help, thanks.

Azard commented 5 years ago
// {app_root}/config/config.default.js
module.exports = config => {
  const exports = {};
  exports.oAuth2Server = {
    debug: config.env === 'local',
    grants: [ 'password' ],
  };
  return exports;
};

check your running environment really load the config file