ahopkins / sanic-jwt

Authentication, JWT, and permission scoping for Sanic
http://sanic-jwt.readthedocs.io
MIT License
242 stars 52 forks source link

How to change /auth and /auth/verify responses? #229

Closed GilmarCorreia closed 2 years ago

GilmarCorreia commented 2 years ago

Hello Sanic Developers,

I am trying to change the format that my API will return the messages from /auth and /auth/verify routes, creating a pattern for my application. When I POST in route /auth, always return:

{
    "access_token" : ".... ",
    "refresh_token" : "..."
}

But I want to encapsulate this, for example:

{
    "success": true,
    "data": {
        "access_token": "...",
        "refresh_token": "....",
    }
}

I've already changed the exception_response, and it is working well. But when I tried to use get_access_token_output or extend_authenticate, the message did not show correctly.

The same thing happens if I want to change the verify returning message.

How can I change these patterners to attend to mine?

ahopkins commented 2 years ago

Does this help?

https://sanic-jwt.readthedocs.io/en/latest/pages/endpoints.html#modify-responses

GilmarCorreia commented 2 years ago

Thank you! But analysing the problem I have modified the response using custom_endpoints.