@@ -35,6 +35,8 @@ public class OAuthAccessToken {
3535 private String tempTokenSecret ;
3636 private int connectTimeout = 20 ;
3737 private int readTimeout = 20 ;
38+ private GenericUrl requestUrl ;
39+ private HttpGet httpget ;
3840
3941 public OAuthAccessToken (Config config ) {
4042 this (config , new ConfigBasedSignerFactory (config ));
@@ -50,36 +52,46 @@ public OAuthAccessToken build(String verifier, String tempToken, String tempToke
5052 this .tempToken = tempToken ;
5153 this .tempTokenSecret = tempTokenSecret ;
5254 this .connectTimeout = config .getConnectTimeout () * 1000 ;
53- this .readTimeout = config .getReadTimeout () * 1000 ;
55+ this .readTimeout = config .getReadTimeout () * 1000 ;
5456
55- httpclient = new XeroHttpContext (config ).getHttpClient ();
56-
57+ httpclient = new XeroHttpContext (config ).getHttpClient ();
58+
59+ requestUrl = new GenericUrl (this .config .getAccessTokenUrl ());
60+ httpget = new HttpGet (this .config .getAccessTokenUrl ());
61+
62+ this .createParameters ().intercept (httpget ,requestUrl );
63+
5764 return this ;
5865 }
5966
6067 public OAuthAccessToken build () throws IOException {
68+ this .connectTimeout = config .getConnectTimeout () * 1000 ;
69+ this .readTimeout = config .getReadTimeout () * 1000 ;
6170 httpclient = new XeroHttpContext (config ).getHttpClient ();
71+
72+ requestUrl = new GenericUrl (this .config .getAccessTokenUrl ());
73+ httpget = new HttpGet (this .config .getAccessTokenUrl ());
74+
75+ this .createRefreshParameters ().intercept (httpget ,requestUrl );
76+
6277 return this ;
6378 }
6479
6580 public boolean execute () throws IOException {
66- GenericUrl requestUrl = new GenericUrl (this .config .getAccessTokenUrl ());
67-
68- HttpGet httpget = new HttpGet (this .config .getAccessTokenUrl ());
69-
70- RequestConfig .Builder requestConfig = RequestConfig .custom ()
71- .setConnectTimeout (connectTimeout )
72- .setConnectionRequestTimeout (readTimeout )
73- .setSocketTimeout (connectTimeout );
74-
75- //Proxy Service Setup - unable to fully test as we don't have a proxy
76- // server to test against.
77- if (!"" .equals (config .getProxyHost ()) && config .getProxyHost () != null ) {
78- int port = (int ) (config .getProxyPort () == 80 && config .getProxyHttpsEnabled () ? 443 : config .getProxyPort ());
79- HttpHost proxy = new HttpHost (config .getProxyHost (), port , config .getProxyHttpsEnabled () ? "https" : "http" );
80- requestConfig .setProxy (proxy );
81- }
82- this .createParameters ().intercept (httpget ,requestUrl );
81+
82+ RequestConfig .Builder requestConfig = RequestConfig .custom ()
83+ .setConnectTimeout (connectTimeout )
84+ .setConnectionRequestTimeout (readTimeout )
85+ .setSocketTimeout (connectTimeout );
86+
87+ //Proxy Service Setup - unable to fully test as we don't have a proxy
88+ // server to test against.
89+ if (!"" .equals (config .getProxyHost ()) && config .getProxyHost () != null ) {
90+ int port = (int ) (config .getProxyPort () == 80 && config .getProxyHttpsEnabled () ? 443 : config .getProxyPort ());
91+ HttpHost proxy = new HttpHost (config .getProxyHost (), port , config .getProxyHttpsEnabled () ? "https" : "http" );
92+ requestConfig .setProxy (proxy );
93+ }
94+
8395 httpget .setConfig (requestConfig .build ());
8496
8597 try {
0 commit comments