1

您好我正在尝试使用 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中定义的回调方法。

提前致谢。

4

0 回答 0