[Django]-Django Authentication from .NET using HttpWebRequest and HttpWebResponse via HTTP POST

2👍

Looks ok to me. I recommend using Wireshark to see what your restclient is sending in the headers and and see what your app sending in the headers.

2👍

If you aren’t doing any session sharing between the two sites and the .Net site has access to the Django app’s DB you could authenticate straight against the db. This question is about how to go from Python to .Net but it should help you out when your hashes don’t exactly match up.

1👍

It’s working now. The HTTP headers were OK, the source of the problem were the following lines:

    Dim encoding As New UnicodeEncoding
    .
    Dim postBytes As Byte() = encoding.GetBytes(postData)

Essentially, this was resulting in a data stream with null bytes between the character bytes. That of course is not what Django authentication expects in the parameters. Changing to ASCIIEncoding solved the problem.

> Looks ok to me. I recommend using Wireshark to see what your restclient is sending in the headers and and see what your app sending in the headers.

This set me off on the right path towards troubleshooting this. I tried with Wireshark, but then used HTTP Debugger which seemed more suited for the job.

The right tools can save one hours!

Leave a comment