您好我正在尝试使用Koa-passport实施密码授予策略。我配置了一个策略如下
passport.use(new PasswordGrantStrategy({
tokenURL: "http://localhost:3001/api/v1/oauth/token",
clientID: "democlient1",
clientSecret: "democlientsecret1",
scope: "profile",
grant_type: "password",
customHeaders: {Authorization: "Basic ZGVtb2NsaWVudDE6ZGVtb2NsaWVudHNlY3JldDE=", scope: "profile" }
},
async (accessToken: string, refreshToken: string, profile: any,
done: (error: any, user?: any, options?: IVerifyOptions) => void) => {
console.log("Details ", accessToken, profile);
done(null, profile);
}));
这就是我尝试验证的方式,
return passport.authenticate("password-grant", {
username: "test",
password: "test"
}, (err: any, user: any, info: any, status: any) => {
console.log("Inside Callback method");
})(ctx, next);
有谁可以帮助我。上面的代码不会调用令牌URL。但是控件进入了passport.authenticate中定义的回调方法。
提前致谢。