I am currently coding an API in Laravel with Dingo and JWT as its authentication
It works fine, and I have set Dingo config to protected
, so a valid JWT token will always need to be there, otherwise it will fail with 401 error. Again it works fine.
The question is .. how can I customise the error message? At the moment it shows like this
{
message: "JWT has expired",
status_code: 401,
debug: { "..."
}
}
At minimum I want to get "JWT has expired" changed to a custom text, either from JWT or Dingo but of course if it can be customised further, it would be great.
Any advice? Thanks
I found a solution
By creating my own provider (or rather extending the default FirebaseProvider) and set the config to use the custom provider
The default is
'provider' => 'Tymon\JWTAuth\Providers\FirebaseProvider'
changed to
'provider' => 'CustomPackages\Providers\MyFirebaseProvider'
I agree that this solution may not be the most elegant way. But it works and I am happy to hear about other solution