package com.xero.api;

import java.io.IOException;
import java.util.HashMap;

import com.google.api.client.auth.oauth.OAuthCredentialsResponse;
import com.google.api.client.auth.oauth.OAuthGetTemporaryToken;
import com.google.api.client.auth.oauth.OAuthSigner;
import com.google.api.client.http.apache.ApacheHttpTransport;

public class OAuthRequestToken 
{

	private String tempToken = null;
	private String tempTokenSecret = null;
	private OAuthGetTemporaryToken tokenRequest = null;
	private Config config;

	public OAuthRequestToken(Config config) 
	{
		this.config = config;
	}

	public void execute() 
	{
		OAuthSigner signer = null;
		if(config.getAppType().equals("PUBLIC"))
		{
			signer = new HmacSigner(config).createHmacSigner();
		}	else {
			signer = new RsaSigner(config).createRsaSigner();
		}

		tokenRequest = new OAuthGetTemporaryToken(config.getRequestTokenUrl());
		tokenRequest.consumerKey = config.getConsumerKey();
		tokenRequest.callback = config.getRedirectUri();

		tokenRequest.transport = new ApacheHttpTransport();

		tokenRequest.signer= signer;

		OAuthCredentialsResponse temporaryTokenResponse = null;
		try 
		{
			temporaryTokenResponse = tokenRequest.execute();

			tempToken = temporaryTokenResponse.token;
			tempTokenSecret = temporaryTokenResponse.tokenSecret;
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
	}

	public String getTempToken()
	{
		return tempToken;
	}

	public String getTempTokenSecret()
	{
		return tempTokenSecret;
	}

	public HashMap<String, String> getAll(){
		HashMap<String,String> map = new HashMap<String,String>();

		map.put("tempToken",getTempToken());
		map.put("tempTokenSecret",getTempTokenSecret());
		map.put("sessionHandle","");
		map.put("tokenTimestamp","");

		return map;
	}
}
@@ -980,24 +980,664 @@
 rectUri();%0A%0A
+%09%09ApacheHttpTransport.Builder  transBuilder = new  ApacheHttpTransport.Builder();%0A%09%09if ( config.getProxyHost() != null && %22%22 !=  config.getProxyHost() ) %7B%0A%09%09%09String proxy_host = config.getProxyHost();%0A%09%09%09long proxy_port = config.getProxyPort();%0A%09%09%09boolean proxyHttps = config.getProxyHttpsEnabled();%0A%09%09%09String proxy_schema = proxyHttps==true? %22https%22:%22http%22;%0A%09%09%09System.out.println(%22proxy.host=%22+proxy_host +%22, proxy.port=%22+proxy_port +%22, proxy_schema=%22+proxy_schema);%0A%09%09%09HttpHost proxy = new HttpHost(proxy_host, (int)proxy_port, proxy_schema);%0A%09%09%09transBuilder.setProxy(proxy);%0A%09%09%09tokenRequest.transport = transBuilder.build();%0A%09%09%7D else %7B%0A%09
 %09%09tokenReque
@@ -1677,16 +1677,20 @@
 sport();
+%0A%09%09%7D
 %0A%0A%09%09toke
@@ -2407,8 +2407,9 @@
 ap;%0A%09%7D%0A%7D
+%0A

Update OAuthRequestToken.java