Question

I've got an XML file on a server. It is protected with an standard Http-Authorization. I want to parse the file. So what is the right way to get the file to the parser?

The authentification string I already have (Base64).

The XML looks like:

    <action>
      <class>11/1,11/2,11/3,11/4/ lat1</class>
      <hour>1</hour>
      <lesson>Eng</lesson>
      <teacher>Schr</teacher>
      <room>E312</room>
      <info>for Lat Gri </info>
    </action>
    <action>
      <class>11/1,11/2,11/3,11/4/ lat1</class>
      <hour>2</hour>
      <lesson>Eng</lesson>
      <teacher>Schr</teacher>
      <room>E312</room>
      <info>for Lat Gri </info>
    </action>
Was it helpful?

Solution

To request a resource over HTTP using Basic Authentication, you need to construct and add the Authorization header line to the request as described in the linked document.

Basically, you add a header line to the request. The name of the field is Authorization and the value is the auth type followed by a space and then the base64 encoded string of the username:password.

So for e.g. if the username is John and the password is secret, you would form a string:

John:secret

and then base64 encode it which will result in:

Sm9objpzZWNyZXQ=

So the full header line to add to the request looks like this:

Authorization: Basic Sm9objpzZWNyZXQ=

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top