[Question] Retrieving the username (Express version)
Is there anyway to get back the username once a user is authenticated ? I.e can you suggest a mechanism to do this ?
Provided you're talking about v3 and not v2 (the version published on npm):
You should be able to access the client and user objects through the result from OAuth2Server#authenticate:
oauthServer.authenticate(req, res)
.then((token) => {
console.log(token.client);
console.log(token.user);
});
Or with express-oauth-server:
app.get('/', oauthServer.authenticate(), (req, res, next) => {
let token = res.locals.oauth.token;
console.log(token.client);
console.log(token.user);
});
If you're using v2 I can't really help you since I've never used it.
Many thanks !
This should really be documented somewhere.
@ruimarinho: Could you add this to whichever v3 milestone you're targeting for documentation?
@maxtruxa Will do
This is now documented here.