-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serializing flask response #31
Comments
Can you elaborate on your use case? Since this is about REST APIs, I assume it is an authentication cookie, right? Do you want to set it from the view function? From a custom authentication decorator? |
Yes, it's auth cookie. So, with flask_restplus this is the code I used: https://github.com/mekanix/backend-startkit/blob/master/application/api/auth.py#L21-L64. Something I tried to achieve with flask_rest_api is this: https://github.com/mekanix/backend-startkit/blob/feature/rest-api/application/api/auth.py#L24-L68. The problem is that frontend says length of response is wrong (I suppose I'm overwriting something). |
I don't see anything blocking you from setting a cookie from a decorator. However, setting a cookie from a view function is currently impossible because by design of the IIUC, the |
Than decorator is the right place. :) Can you please post the code snippet to achieve it? The code I linked to is not the way I have to solve it, it just the closest I've got to setting the cookie, so feel free to just ignore it. |
I have no available snippet and no time for this right now. You might find the conversation in #36 interesting, especially this comment. |
Closing this for now. Feel free to comment if you're still stuck on this. |
I need to set cookies with on some endpoints. Just returning
jsonify({ 'key': 'value' })
does not get serialized. Is there a way to set a cookie in the response together with the "normal" endpoint response?The text was updated successfully, but these errors were encountered: