Friday, March 31, 2017

Customising token response Laravel Passport

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 information with the access tokens, however, I am not sure how to.

Which class could I implement, edit or extend to get this?.

I would like this to be returned:

{
    "token_type": "Bearer",
    "expires_in": 31536000,
    "access_token": "lalalalalal",
    "refresh_token": "lalalallala",
    "user": {
        "username": "a username",
        "user_type": "admin"
    }
}

Thanks in advance.



via Irvin Chan

Advertisement