diff --git a/lib/strategy.js b/lib/strategy.js index ca6fde7..4da4740 100644 --- a/lib/strategy.js +++ b/lib/strategy.js @@ -24,6 +24,8 @@ function PasswordGrantStrategy(options, verify) { this._oauth2 = new OAuth2(options.clientID, options.clientSecret, '', '', options.tokenURL, options.customHeaders); + this._scope = options.scope; + this._scopeSeparator = options.scopeSeparator || ' '; this._passReqToCallback = options.passReqToCallback; this._skipUserProfile = (options.skipUserProfile === undefined) ? false : options.skipUserProfile; } @@ -43,6 +45,13 @@ PasswordGrantStrategy.prototype.authenticate = function(req, options) { params.grant_type = 'password'; params.username = options.username; params.password = options.password; + var scope = options.scope || this._scope + if (scope) { + if (Array.isArray(scope)) { + scope = scope.join(this._scopeSeparator) + } + params.scope = scope + } this._oauth2.getOAuthAccessToken(null, params, function(err, accessToken, refreshToken, params) {