Hi David,

It's actually pretty easy in curl.

curl -d"csrfmiddlewaretoken=a" -H"Cookie: csrftoken=a" http:
//yourdjangosite.com

Collin

On Thursday, April 14, 2011 7:32:46 AM UTC-4, David wrote:
>
> Hello, 
>
> I am sorry for asking this, I know similar questions have been asked 
> before but I could not piece together the answer I needed from 
> previous contribution! 
>
> I have a view, for example: 
>
> @login_required 
> def clever_view(request): 
>     #Render a PDF to a string 
>     response = HttpResponse(content_type='application/pdf') 
>     response.write(pdf_as_string) 
>     return response 
>
> Now, in a browser, if I request http://my.host.name/clever_view.pdf I 
> get sent to the log in page, I log in, and I get my file. If I don't 
> log out I can later on request http://my.host.name/clever_view.pdf and 
> I get the file strait away. The browser handles the session and csrf 
> cookies perfectly. 
> For clarity, the login requires POST inputs 'username', 'password' and 
> the submit button is called 'submit'. 
>
> Now a client wants to use wget or curl to get the file: 
>
> wget http://my.host.name/clever_view.pdf 
>
> However, all I get are 403 even when I POST the username and password, 
> save the cookies and keep the session cookies. 
>
> So in short, how do I access a view when session and csrftoken cookies 
> are required. 
>
> If someone could show me an example of using curl or wget to access a 
> view that is not wrapped with @csrf_exempt but is wrapped with 
> @login_required I would be very grateful indeed. 
>
> Thanks in advance 
>
> Dave 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fb6e54a8-c9e7-45f7-882f-bc05c8ee90d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to