I am trying to send a request to oauth google to get a request token.i passed all the parameters required.here is the code.please help. The out put of the below code is a token provided by google to access its users private data.but i am getting the result that the page i requested is invalid.where did i go wrong? should i pass the scope also in the url?
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
try {
String oauthConsumerKey = "my key";
String oauthSignatureMethod = "HMAC-SHA1";
String oauthSignature = "my signature";
// Send the request
URL url = new URL("https://www.google.com/accounts/OAuthGetRequestToken"+oauthConsumerKey+
oauthSignatureMethod+oauthSignature);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
//write parameters
writer.flush();
// Get the response
StringBuffer answer = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println("\n" +line);
}
writer.close();
reader.close();
//Output the response
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}