C2DM 관련하여 질문드립니다.

 

우선 정상적으로 등록하여 메일도 왔습니다. AuthToken 인증 받는 부분에서 계속 오류가 발새하는 잘몰라 이렇게 글 올리네요..

 

아시는 분 계시면 답변 부탁드립니다.

 

또한 개발자 등록을 해야 하는지요?

 

그럼 수고하세요

 

오류 메세지 ==========================================================

ERROR:getAuthToken - login fail
java.io.IOException: Server returned HTTP response code: 403 for URL: https://www.google.com/accounts/ClientLogin
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
 at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1368)
 at java.security.AccessController.doPrivileged(Native Method)
 at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1362)
 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1016)
 at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
 at com.incross.c2dm.service.C2dmMain.getAuthToken(C2dmMain.java:148)
 at com.incross.c2dm.service.C2dmMain.main(C2dmMain.java:167)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://www.google.com/accounts/ClientLogin
 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1313)
 at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
 at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)
 at com.incross.c2dm.service.C2dmMain.getAuthToken(C2dmMain.java:141)
 ... 1 more

===============================

=========================================================

Thank you for your interest in Android Cloud to Device Messaging (C2DM).
We've accepted your application into the trial group. The Google account
you requested as the sender account for your application:

   tgsvc0001@gmail.com

has been added to our list of allowed senders, and you should be able to
start using it to send messages to Android 2.2 devices within the next
day or so. If at any point you'd like to change the role account used for
sending messages, please fill out the sign-up form again.

By default, all new sender accounts are granted an initial production-level
quota as documented in:

   http://code.google.com/android/c2dm/quotas.html

If you need a higher quota, please follow the instructions on that page
to submit a quota request.

Note that since Android Cloud to Device Messaging is currently an API in Labs,
we reserve the right to fundamentally change the service and associated quotas
at any time.

For more information on Android Cloud to Device Messaging, you can read
our documentation and sample code at:

   http://code.google.com/android/c2dm/

If you have questions or feedback, please visit the Google Group at:

   http://groups.google.com/group/android-c2dm

Please don't reply to this email, since the sender address is unmonitored.

Thanks,
Android Cloud to Device Messaging Team

==================================================================

소스부분

 

  public String getAuthToken() throws Exception{
   String authtoken = "";
      StringBuffer postDataBuilder = new StringBuffer();
      postDataBuilder.append("accountType=HOSTED_OR_GOOGLE");
      postDataBuilder.append("&Email=tgsvc0001@gmail.com");
      postDataBuilder.append("&Passwd=xxxxxxxxxx");
      postDataBuilder.append("&service=ac2dm");
      postDataBuilder.append("&source=ssc7171_01");
 
      byte[] postData = postDataBuilder.toString().getBytes("UTF8");
 
      URL url = new URL("https://www.google.com/accounts/ClientLogin");
     
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setDoOutput(true);
      conn.setUseCaches(false);
      conn.setRequestMethod("POST");
      conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
      conn.setRequestProperty("Content-Length", Integer.toString(postData.length));
 
     
      OutputStream out = conn.getOutputStream();
      out.write(postData);
      out.close();
 
      int responseCode = conn.getResponseCode(); 
     
      if (responseCode == HttpServletResponse.SC_UNAUTHORIZED ||
              responseCode == HttpServletResponse.SC_FORBIDDEN) {
          System.out.println("ERROR:getAuthToken - login fail");
      }
     
      BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
     
      String sidLine = br.readLine();
      String lsidLine = br.readLine();
      String authLine = br.readLine();
     
      System.out.println("sidLine----------->>>"+sidLine);
      System.out.println("lsidLine----------->>>"+lsidLine);
      System.out.println("authLine----------->>>"+authLine);
      System.out.println("AuthKey----------->>>"+authLine.substring(5, authLine.length()));
     
      authtoken = authLine.substring(5, authLine.length());
      return authtoken;
  }