how can get https content of gmail whitout 403 exception?
i want get content of an https url of google but i cannot read the response in my browser i have response but in my app i have 403 exception this code have 403 exception but if open the url in browser i can see the response i want get this response and print in console
public static void main(String args[]) {
try {
String text = "https://www.google.com/accounts/ClientLogin?Content-type=application/x-www-form-urlencoded&accountType=GOOGLE&Email=EMAIL&Passwd=aaaaaa";
URLConnection connection = new URL(text).openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
connection.connect();
BufferedReader r = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charset.forName("UTF-8")));
StringBuilder sb = new StringBuilder();
String line;
while ((line = r.readLine()) != null) {
sb.append(line);
}
System.out.println(sb.toString());
} catch (Exception e) {
e.printStackTrace();
}