Passport - Customising token response

Posted 2 years ago by joshgallagher24

Hi all,

I am working on an API at the moment and have hit a brick wall. I am using Passport with the 'Password' grant type.

I want to return the user's username with the access tokens, however, I am not sure how to.

For example, currently this is returned:

  "token_type": "Bearer",
  "expires_in": 31536000,
  "access_token": "token omitted",
  "refresh_token": "token omitted"
}

However, I would like this to be returned instead:

  "token_type": "Bearer",
  "expires_in": 31536000,
  "access_token": "token omitted",
  "refresh_token": "token omitted",
    "user": {
        "username": "a username"
    }
}

Thanks in advance!

Please sign in or create an account to participate in this conversation.