1

Topic: Authenticating with Indicia not using PHP

Hi all.

I thought I'd like to document how I've done my authentication in a non-PHP way. As it happens, I've done it in Classic ASP (I know)! But the principles should apply to any language. I'll try and be as non-specific as possible.

You firstly need a way of posting to the Indicia warehouse. I'm using a MS component to do this, but any would do...

' Get a nonce from the warehouse
' NB, you need to set the request header to the correct format

url = ".../index.php/services/security/get_read_nonce"

Set xmlHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlHTTP.Open "POST", url, False
xmlHTTP.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
xmlHTTP.Send "website_id=" & WEBSITE_ID

nonce = xmlHTTP.ResponseText

' Now we have the nonce we can combine that with our password to create our auth token...
' You'll need to have a way of applying a sha1 algorithm to it. I haven't included how I've done this.
' It's important that you sha1 the nonce, a colon then the password (in that order).

authToken = Sha1(nonce & ":" & PASSWORD)

You can then use the authToken to access the Indicia warehouse.

Hope this helps anyone who's not using the PHP toolkit.

Regards,

Steve.

2

Re: Authenticating with Indicia not using PHP

Hi Steve

I've done a similar thing but I used c# for my efforts which I just plonked into a library - I'm revisiting this whole area of code at the minute and hope to upload the library for use in .Net thingies...

            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[] bt = encoding.GetBytes(postargs);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            Stream st = request.GetRequestStream();
            st.Write(bt, 0, bt.Length);
            st.Close();
            StreamReader stIn = new StreamReader(request.GetResponse().GetResponseStream());
            string strResponse = stIn.ReadToEnd();
            stIn.Close();
            return strResponse;

Ta

Iain