emuikernel / wittytwitter

Automatically exported from code.google.com/p/wittytwitter
1 stars 0 forks source link

Enhancement: Proxy Configuration #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
As an enhancement perhaps allow the setting of a proxy connection?

Original issue reported on code.google.com by michael....@gmail.com on 25 Oct 2007 at 6:23

GoogleCodeExporter commented 8 years ago
this would be lower on the list of priorities as other twitter clients do not 
support
this.  Not sure the percentage of users that uses a proxy connection.

Also, I would like to spend more time on core wpf-specific functionality like
skinning support and notifications.

Thanks for the enhancement idea though.

Original comment by alan...@gmail.com on 25 Oct 2007 at 7:45

GoogleCodeExporter commented 8 years ago
Well I can't use Witty from work because I keep getting a "The remote server 
returned an error: (407) Proxy Authentication Required."

<code>
Usually doing the following works:
IWebProxy proxy = WebRequest.GetSystemWebProxy();
proxy.Credentials = CredentialCache.DefaultCredentials;

WebRequest myRequest = WebRequest.Create(someUri) as HttpWebRequest;
myRequest.Proxy = proxy;
</code>

I tried this in the 0.1.3 source you had available and it didn't help.  I will 
get 
the source for the current stable release and see if I can figure it out.

Original comment by tena...@gmail.com on 30 Oct 2007 at 2:44

GoogleCodeExporter commented 8 years ago
Since I was very eager to use Witty behind my companies firewall I have put a 
little 
effort into figuring out a fix for the "(407) Proxy Authentication Required." 
error 
and I wanted to post what I have discovered. 

I was able to get Witty to run behind my firewall by adding my proxy network 
credentials to all of the HttpWebRequset objects used in the TwitterLib.  First 
I 
tried using the DefaultCredentials but that didn't work. 

Example from the TwitterNet.Login method: 

Public User Login() 
{ 
     ... 
     // Create the web request 
     HttpWebRequest request = WebRequest.Create(timelineUrl) as 
           HttpWebRequest; 

     // Add Proxy Authentication 
     request.Proxy = new NetworkCredential 
              "MyDomainUserName", "MyDomainPassword", "MyDomain"); 

     // Add credendtials to request 
     request.Credentials = new NetworkCredential(username, password); 
     ... 
} 

To reduce the amount of duplication I create a private IWebProxy 
object: 

private IWebProxy _webProxy; 

Initialized it in the TwitterNet constructor: 

_webProxy = WebRequest.GetSystemWebProxy(); 
_webProxy.Credentials = 
     new NetworkCredential("MyDomainUserName", "MyDomainPassword", "MyDomain"); 

And then used it on all HttpWebRequest objects: 
// Add Proxy Authentication 
request.Proxy = 
      new NetworkCredential("MyDomainUserName", "MyDomainPassword", "MyDomain"); 

// Add credendtials to request 
request.Credentials = new NetworkCredential(username, password); 

I think the complete solution would require a little more work and adding a 
section 
the the options screen that would have a checkbox to use proxy authentication 
and 
fields for the user to supply the needed proxy authentication information then 
that 
info would need to be made available to the TwitterNet object. 

Anyway,  I have it hardcoded at the moment and I have been able to login, see 
my 
Twitters and the ones I am following and was able to successfully add a Tweet. 

I hope you find this useful and if you would like me to post the modified 
TwitterNet.cs I would be happy two.  The version I am working with the the 
latest 
that was in your subversion tree as of 8:00 AM CST 10/31/2007. 

Jay Smith 
http://jaysmith.us 

Original comment by tena...@gmail.com on 1 Nov 2007 at 1:34

GoogleCodeExporter commented 8 years ago
Tenanji, that's great! I'll see if I can make this configurable for proxy using 
your
code above. I'm not sure if this will make it in v0.1.5 though.

making this issue as High.

Original comment by alan...@gmail.com on 1 Nov 2007 at 6:19

GoogleCodeExporter commented 8 years ago
If you use the NetworkCredential for your proxy, and add the Basic auth header 
to the
request manually, will the request still pass, and be accepted both by the local
proxy, and by Twitter?

Original comment by andrew.b...@hotmail.com on 2 Jan 2008 at 8:11

GoogleCodeExporter commented 8 years ago
This would be a much wanted feature. Currently Witty works for a few minutes 
after
opening and then fails with the "(407) Proxy Authentication Required." as 
mentioned. 
Might have to get the source down and add in the fix manually until it's 
officially
added. 
Sweet App, btw. WPF rocks!

Original comment by lyt...@gmail.com on 25 Jan 2008 at 1:58

GoogleCodeExporter commented 8 years ago
WPF is still .net - modify the Witty.exe.config and add a
system.net/defaultProxy/proxy section with your proxy info.  Mine looked 
something like:

  <system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true">
      <proxy usesystemdefault="false" proxyaddress="http://proxy:8080"/>
    </defaultProxy>
  </system.net>

Now witty is working though a the proxy.  (We use an NTML proxy here - for 
basic auth
you can pass in the username and password on the defaultProxy line).  I would
recommend just adding a dialog to witty to change these settings from within 
the UI

Original comment by michael....@gmail.com on 8 Feb 2008 at 3:21

GoogleCodeExporter commented 8 years ago
I've made some changes to do this, but the source is too big to attach here.  
Where
can I send it so that it can be reviewed?

Original comment by bmsulli...@gmail.com on 17 Mar 2008 at 3:03

GoogleCodeExporter commented 8 years ago
I figured out what files I'd changed, and just zipped those up.  Hopefully these
enhancements aren't duplicates of something you're already working on.  I tried
sending Alan a couple of messages on Twitter, but I never got a response.  :-(

Original comment by bmsulli...@gmail.com on 19 Mar 2008 at 2:12

Attachments:

GoogleCodeExporter commented 8 years ago
bmsullivan,
can you make an svn patch from your changes?

Original comment by alan...@gmail.com on 20 Mar 2008 at 12:41

GoogleCodeExporter commented 8 years ago
I didn't find WebProxyHelper in your zip file.

Original comment by alan...@gmail.com on 20 Mar 2008 at 4:59

GoogleCodeExporter commented 8 years ago
ok, I merged bmsullivan's patch with my changes to the project and options 
window.
Need testers.

Original comment by alan...@gmail.com on 20 Mar 2008 at 8:17

GoogleCodeExporter commented 8 years ago
marking as fixed

Original comment by alan...@gmail.com on 24 Mar 2008 at 8:58