0
votes

I am trying to implement basic authentication in my Worklight project.

I set the following code in the adapter xml.

    <authentication>
        <basic/>
        <serverIdentity>
        <username>admin</username>
        <password>admin</password>
        </serverIdentity>
    </authentication>

All my procedures have to have this basic authentication, so I set my procedures like this:

    <procedure connectAs="server" name="getClass">
    <displayName>getClass</displayName>
    <description>Retrieves classdetails by id</description>
</procedure>

I get following error when I implement this:

    FWLSE0101E: Caused by:  [project Klappr]java.io.IOException: Unexpected character '<' on line 1, column 1 
                                                                                                           com.worklight.common.log.filters.ErrorFilter

When I don't implement it, I get a 401 error, because no authentication object is given.

    [11:26:43.403] "Transfer failed, errors = Runtime: Failed to parse JSON string
    Error 401: An Authentication object was not found in the SecurityContext"

How can I mock this to username 'admin', password 'admin' instead of implementing the whole Worklight security before?

Info about the basic authentication :

    http://pic.dhe.ibm.com/infocenter/wrklight/v5r0m5/index.jsp?topic=/com.ibm.worklight.help.doc/devref/r_the__authentication__element_o.html
1

1 Answers

0
votes

Adapter is used for connecting to a backend. Using authentication in WL adapter means that your backend requires basic authentication.

You're getting error message because you've specified returnedContentType:"json" and your backend returns XML/HTML. Set returnedContentType to "plain" in order to see your backend response.