code_android_festival_way wrote:
> Hello guys!
> 
> I'm trying to achieve a basic HTTP authentication. After hours of try
> and error I'd like to ask you what is the right way at the moment to
> achieve that.
> 
> Here is my source code at the moment:
> 
> http://rafb.net/p/ii4mMi16.html
> 
> This approach doesn't work and I don't really get why. (with normal
> Java applications it works just fine)
> 
> I'm really looking forward getting some ideas from you.

Some random thoughts:

-- At line #42, you call client.getHostConfiguration().getHost() and 
client.getHostConfiguration().getPort(). I would assume they return null 
and -1 respectively. I definitely can't see how they could be Twitter's 
host/port, since HttpClient hasn't been told about Twitter by that line 
in the code. Now, as it turns out, AuthScope.ANY_HOST and 
AuthScope.ANY_PORT *happen* to be null and -1, so this line works, but 
you might want to make that explicit rather than relying upon the 
not-connected defaults.

-- You haven't told us how the code doesn't work. If the answer is that 
Twitter is not accepting the authentication (e.g., you're getting a 401 
Unauthorized back), try adding AuthScope.REALM to your AuthScope, as 
I've run into problems from time to time with invalid realms with HTTP 
auth. If the code is failing in some other way (exception, other 
response code from Twitter), let us know the details.

-- You're sure the Fail Whale wasn't showing up on the Twitter site when 
you tried your code, right? ;-)

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android Training on the Ranch in September! http://www.bignerdranch.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to