laravel-json-api: [Question] Customize Authorization Exception Response

I am working with passport scopes to authenticate specific actions. First of all, I ran into the issue that the scope middleware, provided by passport, does not play nicely with the json-api. For Example $api->resource('my-resource')->only('index')->middleware('scope:my-resource:index'); only returns a 500 internal server error instead of the 403 with details on the missing scope. As an alternative, I’d like to move the logic from the routes file to the authorizer. Unfortunately, I don’t see any possibility to customize the response error text for the authorization exception, since the api only returns {"title": "Unauthenticated"} along with the 403 response code.

Is there any possibility to customize the response like “You need scope XY to access this resource”?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (16 by maintainers)

Most upvoted comments

Closing this as I think we reached a conclusion.