Reputation: 1559
I have an authentication webservice sitting at http://example.com:9080/auth/login that accepts a POST request with www-url-form-encoded encoding and responds back in JSON format.
I am currently going through the Adapter-based Authentication tutorial. Inside the body of submitAuthentication(username, password) in SingleStepAuthAdapter-impl.js, I have the following:
function submitAuthentication(username,password):
var input = {
method: "post",
path: '/auth/login',
returnedContentType: 'json',
body: {
content: JSON.stringify({"username":username, "password":password}),
contentType: "application/x-www-url-formencoded;charset=utf-8"
}
var returnData = WL.Server.invokeHttp(input)
The problem I am having is that the server (locally hosted websphere) is not receiving my username and password. Am I missing something here?
Upvotes: 0
Views: 357
Reputation: 2132
You could add a header to the request with basic authentication credentials such as:
var input = {
method: "post"
returnedContentType: 'application/json',
path: path,
headers: {
'Authorization': 'Basic '+ base64_encode(username+':'+password),
You could also make the request and then store a secure cookie and attach it as a header on future requests following this post:
Attaching cookie to WorkLight Adapter response header
Upvotes: 2