我在node.js应用程序中实现Oauth2身份验证时遇到问题,我需要在授权请求中添加一个额外的参数,但是该模块只是忽略了“未知”参数。
我的代码附在下面。被忽略的参数是APIName。
var OAuth2Strategy = require('passport-oauth2').Strategy;
// load the auth variables
var configAuth = require('./auth');
module.exports = function(passport) {
passport.use('ihealth', new OAuth2Strategy({
authorizationURL: 'https://api.ihealthlabs.com:8443/OpenApiV2/OAuthv2/userauthorization/',
tokenURL: 'https://api.ihealthlabs.com:8443/OpenApiV2/OAuthv2/userauthorization/',
clientID: configAuth.iHealthAuth.clientID,
clientSecret: configAuth.iHealthAuth.clientSecret,
callbackURL: configAuth.iHealthAuth.callbackURL,
APIName : 'OpenApiActivity'
},
function(token, refreshToken, profile, done) {
// ...
}
));
};
Run Code Online (Sandbox Code Playgroud)
我知道APIName被忽略的原因是,我在浏览器中看到该URL:
https://api.ihealthlabs.com:8443/OpenApiV2/OAuthv2/userauthorization/?response_type=code&redirect_uri=SOMEREDIRECTURI&client_id=SOMECLIENTID
Run Code Online (Sandbox Code Playgroud)
我想知道如何启用向授权请求中添加其他参数?也许通过重写功能OAuth2Strategy.prototype.authorizationParams中node_modules/passport_oauth2/lib/strategy.js,它看起来像这样在donwloaded文件:
/**
* Return extra parameters to be included in the authorization request.
*
* Some OAuth 2.0 providers allow additional, non-standard parameters to …Run Code Online (Sandbox Code Playgroud)