Consuming an external web service with Authentication

3 posts, 0 answers
  1. luke
    luke avatar
    9 posts
    Member since:
    Jun 2011

    Posted 13 May 2013 Link to this post

    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. luke
    luke avatar
    9 posts
    Member since:
    Jun 2011

    Posted 14 May 2013 Link to this post

    I managed to get this working by encoding the username:password combination

    Now just make sense of the data

    Luke
  3. JonathanElsner
    JonathanElsner avatar
    20 posts
    Member since:
    Feb 2004

    Posted 03 Oct 2013 Link to this post

    Luke, I need the same thing.  Can you give me an example of how you got this to work?  Thanks.
Back to Top