【发布时间】:2012-03-10 13:21:30
【问题描述】:
我正在尝试使用一个简单的 Java 程序向 Google 进行身份验证。我使用我的凭据发布到正确的 URL。我收到带有 HTTP 状态代码 200 的响应,但其中不包含我为用户检索提要所需的任何身份验证令牌。这是代码
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 的其余部分之间真的有两个空格? -
对不起,这只是一个错字。
标签: java http token authentication