I have the same error message and the solution is not available as everyone has there own thought.
So What works for me If you extended AccessToken according to reference given in loopback-component-passport,
Just don't remove base AccessToken from model-config keep both. Don't worry as loopback only going to use extended model to keep Token.
model-config.json
`'....
,
"AccessToken": {
"dataSource": "adnexux",
"public": false
},
"accessToken": {
"dataSource": "adnexux",
"public": false
},
...'`
Then Just add this to middleware.json
`....
,
"loopback#token": {
"params": {
"model": "accessToken"
}
}
},
...`
If Error Is without Extending the accessToken:
Then Just check model config if model is connected to data source.
`....
"AccessToken": {
"dataSource": "adnexux",
"public": false
},
.....`
And To get current User you can paste this code in server.js
`'app.use(function setCurrentUser(req, res, next) {
if (!req.accessToken) {
return next();
}
app.models.user.findById(req.accessToken.userId, function(err, user) {
if (err) {
return next(err);
}
if (!user) {
return next(new Error('No user with this access token was found.'));
}
res.locals.currentUser = user;
next();
});
});'`