我正在尝试使用简单的Java程序与Google进行身份验证。我用我的凭证发布到正确的URL。我收到了HTTP状态代码200的响应,但没有包含我需要为用户检索提要的任何身份验证令牌。下面的代码使用Java apache http令牌进行Google身份验证
private static String postData = "https://www.google.com/accounts/ClientLogin?Content-type=application/x-www-form-urlencoded&accountType=GOOGLE&Email=xxxxxxxx&Passwd=xxxxx";
public GoogleConnector(){
HttpClient client=new DefaultHttpClient();
HttpPost method=new HttpPost(postData);
try{
HttpResponse response=client.execute(method);
System.out.println(response.toString());
}
catch(Exception e){
}
这是你在发布你的代码示例时发生了一个错误,还是在'Content-'和你的其余URL之间真的有两个空格? – Perception 2012-03-10 13:36:27
啊,对不起,它只是一个错字。 – user1261046 2012-03-10 13:38:57