Django request.POST is empty

Im using django, allauth and dj-rest-auth. I'm implementing apple sign in. There is an issue with apple that I need multiple client_id's configured, its because you need a different one for ios en android/web. The issue is discussed here: https://github.com/pennersr/django-allauth/issues/2718 With also some solutions.

Anyway, my question is not about that issue. I'm trying to implement a solution but django is not working like I expect it to. The issue is that that I cant access request.POST data. Which I think should be possible.

# We add client_id when we make the post request, and we use it to filter for it
def list_apps(self, request, provider=None, client_id=None):
    print(request.POST)     --> returns empty dict
    # print(request.body)   --> error
    # print(request.data)   --> error
    assert False
    print(request.POST.get('client_id'))
    apps = super().list_apps(request=request, provider=provider, client_id=client_id)
    return apps

request.body gives the error: django.http.request.RawPostDataException: You cannot access body after reading from request's data stream

request.data gives the error: AttributeError: 'WSGIRequest' object has no attribute 'data'

I would expect that I can access at least one of request.body, request.data or request.POST. Or else how can I access my posted data?

I have an idea about why it might happen, but I'm not sure.

The function validate is called in the SocialLoginSerializer. That function eventually calls list_app from the DefaultSocialAccountAdapter. That is the function that I'm overwriting above.

I suspect that request.POST is only filled after the serializer function is ran. So if you then check for request.POST, request.body or request.data inside the validate fucntion. They are all empty/give error.

Back to Top