SilverHoodCorp / gdata-java-client

Automatically exported from code.google.com/p/gdata-java-client
Apache License 2.0
0 stars 0 forks source link

It's not possible to auth using an HTTP proxy #315

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I am trying to use the gdata java client with an HTTP proxy and as far as I can 
tell, this is only possible for sending requests but not authentication which 
means using this library with an HTTP proxy is not possible without setting a 
global HTTP and HTTPS proxy through properties.

I'm able to set connection source for the HttpGDataRequest.Factory for the 
service I am using with this code: 

HttpGDataRequest.Factory reqFactory = (HttpGDataRequest.Factory) 
someService.getRequestFactory();
        reqFactory.setConnectionSource(ProxiedJdkHttpUrlConnectionSource.INSTANCE);

where ProxiedJdkHttpUrlConnectionsSource overrides JdkHttpUrlConnectionsSource 
and calls openConnection(someProxy) for the URL in the openConnection method.

This all works fine and dandy except there is no setConnectionSource specified 
for the GoogleAuthTokenFactory class.  Moreover, in setCredentials(String, 
String, String, String, ClientLoginAccountType), a new GoogleAuthTokenFactory 
is instantiated for each call so calling setConnectionSource would not be 
possible since the auth token factory used cannot be retrieved from a getter, 
as in the case of getRequestFactory().

What is the expected output? What do you see instead?

It would be awesome if this were possible and I think the following changes 
would make authing via proxy possible:

1) Make the GoogleAuthTokenFactory a protected member in GoogleService.
2) Add a getter for this factory e.g. getAuthFactory()
3) Add a member HttpUrlConnectionSource in GoogleAuthTokenFactory that is 
initialized to JdkHttpUrlConnectionSource.INSTANCE
4) Add a setter setConnectionSource(HttpUrlConnectionSource) in 
GoogleAuthTokenFactory
5) Change GoogleAuthTokenFactory::makePostRequest to use the member 
HttpUrlConnectionSource to get the connection rather than calling 
openConnection directly on the passed in URL.

This is the pattern used for HttpGDataRequest.Factory when setting an alternate 
connection source and AFAIK is the only way to get HTTP proxying working.  

What version of the product are you using? On what operating system?

Java sdk 1.6
1.42.0
Mac OSX

Please provide any additional information below.
It blows my mind that this library does not work with proxy support out of the 
box (no I do not want to set global proxy rules)

Original issue reported on code.google.com by derrickh...@gmail.com on 3 Nov 2010 at 8:14

GoogleCodeExporter commented 9 years ago
I need this solution, could you post a example code? very thansk!

Original comment by cftalav...@gmail.com on 6 Jun 2011 at 4:57