我正在尝试使用node-oauth2-library实现Oauth2.0的client_credentials授予类型,这是我的oauth2Server代码段
const Model = require('./services/oauth2_service');
app.oauth = new oauthServer({
model: Model,
grants: ['client_credentials'],
debug: true
});
app.all('/oauth/token', (req, resp) => {
let request = new Request(req);
let reponse = new Response(resp);
return app.oauth.token(request, reponse);
});
这是我的模特:
module.exports = {
getAccessToken: (bearerToken, callback) => {
access_token.findOne({
accessToken: bearerToken
}, callback);
},
getClient: async (clientId, clientSecret, callback) => {
// console.log(new Request());
let record = await client.findOne({clientId: clientId, clientSecret: clientSecret});
if (record) {
callback(null, record);
} else {
callback ("Client not found", null);
}
}
}
现在我如何获得对诸如getClient之类的内部请求的访问。任何帮助,将不胜感激。谢谢。