2010-12-07 6 views
1

私はC2DMのサーバー側を実装しようとしています。登録手続きを経てGoogleに自分のアプリケーションを登録し、確認メールを受け取ったので、私のuser/pwdは良いはずです。最初のステップは、ClientLoginを介してauthトークンを取得することです。コードを実行すると、応答コード403/Forbiddenが返されます。誰にでもアイデアはありますか?C2DMサーバー側ClientLogin with Java問題

log.info("Obtaining the Google C2DM Client Login token."); 

    // Make POST request 
    HttpResponse res = null; 
    try { 
     DefaultHttpClient client = new DefaultHttpClient(); 
     URI uri = new URI("https://www.google.com/accounts/ClientLogin"); 

     List<NameValuePair> params = new ArrayList<NameValuePair>(); 
     params.add(new BasicNameValuePair("accountType", "HOSTED_OR_GOOGLE")); 
     params.add(new BasicNameValuePair("Email", "[email protected]")); 
     params.add(new BasicNameValuePair("Password", "MY_PWD")); 
     params.add(new BasicNameValuePair("service", "ac2dm")); 
     params.add(new BasicNameValuePair("source", "MY_APP-V0.1")); 

     HttpPost post = new HttpPost(uri); 
     UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8"); 
     post.setEntity(entity); 
     res = client.execute(post); 
    } catch (Exception e) { 
     log.error("Error obtaining the Google C2DM Client Login token.", e); 
    } 

    log.debug("response="+res); 
    if (res != null) { 
     log.debug("Response status code = "+res.getStatusLine().getStatusCode()); 
     log.debug("Response status  = "+res.getStatusLine().getReasonPhrase()); 
    } 

答えて

1

私の問題は、ここで私に指摘された: http://blog.boxedice.com/2010/10/07/android-push-notifications-tutorial/

"パスワード" パラメータ名は、実際に "passwd" ファイルでなければなりません。 答えのためにDannonに感謝します。

+0

ええと、私も403を取得していますが、すべてのパラメータは正しいです...そして応答の追加情報はありません – Ted

関連する問題