我正在嘗試通過編程方式向Google應用引擎進行身份驗證。 我試着從「GAE-APP-經理」項目中的代碼示例,但它失敗:如何以編程方式向Google應用引擎(使用Java)進行身份驗證?
tmp>java -jar net.sf.gae-app-manager-0.0.1-jar-with-dependencies.jar [email protected] mypassword appname
Exception in thread "main" java.lang.Exception: Did not find ACSID cookie
at net.sf.gaeappmanager.google.LogonHelper.loginToGoogleAppEngine(LogonHelper.java:85)
at net.sf.gaeappmanager.google.appengine.Manager.retrieveAppQuotaDetails(Manager.java:34)
at net.sf.gaeappmanager.google.appengine.Main.main(Main.java:55)
任何想法?我能夠獲得令牌,但沒有cookie。 代碼(從GAE-APP-Manager項目採取 - http://gae-app-manager.git.sourceforge.net/git/gitweb.cgi?p=gae-app-manager/gae-app-manager;a=blob;f=src/main/java/net/sf/gaeappmanager/google/LogonHelper.java;h=8e09a6d7f864c29b10847ac7fd2eeab2d3e561e6;hb=HEAD):
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
52 nvps.add(new BasicNameValuePair("accountType", "HOSTED_OR_GOOGLE"));
53 nvps.add(new BasicNameValuePair("Email", userid));
54 nvps.add(new BasicNameValuePair("Passwd", password));
55 nvps.add(new BasicNameValuePair("service", "ah"));
56 nvps.add(new BasicNameValuePair("source", source));
57
58 HttpPost post = new HttpPost(
59 "https://www.google.com/accounts/ClientLogin");
60 post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
61
62 HttpResponse response = client.execute(post);
63
64 if (response.getStatusLine().getStatusCode() != 200) {
65 throw new Exception("Error obtaining ACSID");
66 }
67
68 String authToken = getAuthToken(response.getEntity().getContent());
69
70 post.abort();
71
72 HttpGet get = new HttpGet(
73 "https://appengine.google.com/_ah/login?auth=" + authToken);
74
75 response = client.execute(get);
76
77 for (Cookie cookie : client.getCookieStore().getCookies()) {
78 if (cookie.getName().startsWith("ACSID")) {
79 return cookie.getValue();
80 }
81 }
82
83 get.abort();
84
85 throw new Exception("Did not find ACSID cookie");
感謝,
李
能否請你幫我在這裏http://stackoverflow.com/questions/23306993/google-apps-customized-google-login-page- in-appspot – 2014-04-28 15:25:26