This is a migrated thread and some comments may be shown as answers.

Consuming an external web service with Authentication

2 Answers 153 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
luke
Top achievements
Rank 1
luke asked on 14 May 2013, 01:24 AM
Hi All

Ho do i consume data from a web service in a different domain ? I have tried the dataSource approach (http://www.kendoui.com/forums/framework/data-source/authenticating-to-a-data-source.aspx) but this appears to be a no good for me.

cross domain requires Jsonp for which I cannot set headers for authentication. 

Cors has been enabled on the server, and i can see the headers come back. I have tried the following:

var url = 'XXX web service url';
url = url + '?enable_cors_headers=true&enable_http_auth=true';
var req = new XMLHttpRequest();
req.onload = function() { console.log(this.responseText); };
req.open('get', url, true);
req.setRequestHeader('Accept', 'application/json');
req.setRequestHeader('Authorization', 'Basic 6b1be1a046ff19e26683572ac5a7d07e');
//also tried the following with correct username and password
//req.setRequestHeader('Authorization', 'Basic username:password');
req.send();

Icenium debuger console just shows 401 error no matter what i try


Add the web service in a browser, and it comes and asks for credentials, add them in and its fine

How do other people access a secured web service in icenium ???

I can get it working in eclipse, but i want to build across platform, and want to use icenium, I just cant find out how.

Thanks

Luke

2 Answers, 1 is accepted

Sort by
0
luke
Top achievements
Rank 1
answered on 14 May 2013, 06:03 AM
I managed to get this working by encoding the username:password combination

Now just make sense of the data

Luke
0
JonathanElsner
Top achievements
Rank 1
answered on 03 Oct 2013, 07:32 PM
Luke, I need the same thing.  Can you give me an example of how you got this to work?  Thanks.
Tags
General Discussion
Asked by
luke
Top achievements
Rank 1
Answers by
luke
Top achievements
Rank 1
JonathanElsner
Top achievements
Rank 1
Share this question
or