On Tue, Jan 13, 2009 at 2:16 PM, Dimebrain <[email protected]> wrote: > > Yes, you nailed it. I want to insert a script tag to send the request, > and somehow attach auth info to it going out the door, and your answer > is what I feared but suspected; no, I can't do that. If I use a server > proxy I might as well just have a service that sends and receives > messages to and from the API from my server. I was hoping to be able > to keep everything on the client-side; can you use a server proxy > without leaving the client, i.e., so that the json callback has > somewhere to call back to?
Yes. Using jQuery or something similar to create an ajax request, when the data is returned from the server proxy, just call "eval(data);" (where 'data' is the data returned from the server), and it will execute 'data' (meaning, it will call the callback if the json response is wrapped in one). If you've never done an ajax request from javascript before, see http://docs.jquery.com/Ajax/jQuery.ajax#options and look at the examples (pay close attention to the "success" option since this is where the data will be "sent" upon return from the server). > > Maybe the better question to ask is whether Twitter API calls that > support JSON callbacks are all non-auth methods. I'm not sure of that answer (it is probably 'no'), but the better answer is "not-necessarily", so you'll have to determine if you need a proxy for each type of request. hth, /* Chad */ > > On Jan 13, 1:02 pm, "Chad Etzel" <[email protected]> wrote: >> I'm assuming that by "injecting javascript to make the request" you >> mean just inserting <script> tags in the page, then there is no way >> (to my knowledge) to send along HTTP auth info with that sort of >> request. In my experience, since Cross-Site ajax requests are not >> allowed, the only way to make requests that require HTTP auth is to >> use some sort of server proxy. Is that what you are asking? I'm not >> sure I totally got your question. >> -Chad >> >> On Tue, Jan 13, 2009 at 9:22 AM, Dimebrain <[email protected]> wrote: >> >> > I realize session auth isn't supported, but considering that JSONP >> > callbacks are, is it possible to avoid a prompt for username and >> > password when making requests w/ JSON callbacks that require them? >> > Since I'm basically just injecting javascript to make the request, >> > it's not obvious to me how to send the username and password along >> > with it, even if I'm providing it each and every time without making a >> > "real" cross-domain request which isn't possible. All All I'm after is >> > a way to explicitly provide the username/password rather than submit >> > to a prompt. >
