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

Trying to get odata from a site with basic authentication

1 Answer 155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 18 Apr 2014, 08:31 PM
I've been trying to solve this problem for a while with no luck. I'm trying to get some odata with the following code:

var dataSource = new kendo.data.DataSource({
    dataType: "odata",
    transport: {
        read: {
            url: "http://localhost:8080/odata/SDA/TEIID_TEST",
            beforeSend: function(req){
               req.setRequestHeader('Authorization','Basic dXNlcjp1c2Vy');
            }
        }
    }
 });
dataSource.read();  

Which seems like the right thing to do, given the other posts I've read on this subject. But when I actually look at what's going on using Tamper in Firefox, it sends an OPTIONS request. On the other hand, when I repeat the code used above WITHOUT the beforeSend part, it sends a GET request - but still no luck of course, because I can't authorize. 

How do I get around it? (Here's a StackOverflow post I made for reference, complete with screenshots.)


1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 22 Apr 2014, 03:32 PM
Hello Daniel,

When you do cross-domain requests then it is normal to see the OPTIONS request sent first followed by the GET request. Most probably the problem is that you have not allowed the OPTIONS requests on the server. 

You can see the above mentioned behavior in our demos as well:

http://www.screencast.com/t/FSfpClfb8

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or