Getting UserInfo using the Access Token

It a simple https get call, as of now I am using Insomnia similar to postman to try to get the userinfo.
The url is as mentioned before and the headers contain Bearer and AccessToken obtained from the Web Server.

I would like a code sample like this which obtains the access token to either get or post passing the existing Bearer token and obtain the userinfo

function getAccessToken(req, res, next){
  request
    .post('https://YOUR-AUTH0-DOMAIN.auth0.com/oauth/token')
    .send(authData)
    .end(function(err, res) {
      req.access_token = res.body.access_token
      next();
    })
}