Objective Resource, Vodafone 3G, HTTP Basic Auth problems
I haven’t posted in a few days, as I haven’t made any progress in the last few days (and haven’t learnt anything!).
I got my app working perfect (unbeknown to me only on a wireless connection, iPhone App people, iPHONE!.. keep up.)
So it worked perfectly, I installed it on a colleague’s iPhone, then my Boss’s iPhone. All good I thought! Then on the bus home I decided to try it (while on a 3G connection over Vodafone, Vodafone being the only provider in New Zealand which has iPhone’s). It wouldn’t work!
The following 2 days I spent trying to figure it.
Turns out I still don’t know whats going on. It appears the 3G network might have a proxy, and that proxy might strip my Basic Auth headers. It seems like that… Then I tried Safari on the iPhone to load a page requiring Basic Auth, BAM! it worked.. Ok, so you can see where this is going. It made no sense, it didn’t at any point after this either.
Well, it still doesn’t make sense to me. But I got it working.
authenticate_or_request_with_http_basic do |username, password|
user = User.authenticate(username, password)
current_user = user if user
end
I hijacked the restful_authentication rails plugin to ASK for authentication. This seemed to work, even though I would not catch the initial failure and resend with credentials. I just send with them the first (and subsequent) requests. This all resulted in the server responding once, or twice (appears random), with a 401, which then followed with a 200 as the Basic Auth details got through.
It’s very odd, but it works now.
Related Posts
In: Iphone · Tagged with: iPhone, Objective Resource
on January 8, 2011 at 6:36 am
Permalink
Hi John,
This is really a odd problem. But it’s good to know that you found a workaround. I bookmarked this post just in case I face this problem in the future.
I’m starting to learn Objective C and iPhone development and I got to develop a app that communicates with a database in a local server.
I found ObjectiveResource and it is a very interesting way to make the connection I need. But the project seems to don’t have a update for a while.
Can you give me some recommendations? Is ObjectiveResource really the best alternative to consume a Webservice?
Thanks a lot in advance!