Unable to parse payload: payload [0] = <(Android RequestFactory not authenticated)

I am developing an app with GAE and Android using RPC. But when I try to send RPCall from android to server. I am getting the following error.

03-14 12:00:57.445: E/AndroidRuntime(30718): FATAL EXCEPTION: IntentService[[email protected]]
03-14 12:00:57.445: E/AndroidRuntime(30718): java.lang.RuntimeException: Could not parse payload: payload[0] = <
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.web.bindery.autobean.vm.impl.JsonSplittable.create(JsonSplittable.java:70)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.web.bindery.autobean.shared.impl.StringQuoter.split(StringQuoter.java:73)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.web.bindery.autobean.shared.AutoBeanCodex.decode(AutoBeanCodex.java:54)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$StandardPayloadDialect.processPayload(AbstractRequestContext.java:323)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$5.onTransportSuccess(AbstractRequestContext.java:1108)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.cloudsmsplus.util.AndroidRequestTransport.send(AndroidRequestTransport.java:68)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.doFire(AbstractRequestContext.java:1102)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.fire(AbstractRequestContext.java:569)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequest.fire(AbstractRequest.java:54)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequest.fire(AbstractRequest.java:59)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.cloudsmsplus.c2dm.DeviceRegistrar.registerOrUnregister(DeviceRegistrar.java:70)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.cloudsmsplus.C2DMReceiver.onRegistered(C2DMReceiver.java:51)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.android.c2dm.C2DMBaseReceiver.handleRegistration(C2DMBaseReceiver.java:191)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at com.google.android.c2dm.C2DMBaseReceiver.onHandleIntent(C2DMBaseReceiver.java:110)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at android.os.Looper.loop(Looper.java:137)
03-14 12:00:57.445: E/AndroidRuntime(30718):    at android.os.HandlerThread.run(HandlerThread.java:60)

      

The user must be authenticated to access my application, so I set the security limit to * for each url. Even though I am creating a cookie, I am getting this error. I think the answer I am getting is the login page.

In my case, I am sending an RPCall to register a device for C2DM. And most of the code I am using was generated from an Android project linked to Appengine. Someone has already found a workaround or fix this.

PS: I am using GAE 1.6.3, Android API v8, GWT 2.4.0 (but I think it doesn't matter)

Edit:

Ok, I found something new. If you send something from Android to App Engine using RPC, the client is not actually authenticated. You just get a token, then a cookie, and then (so I think) the RequestFactory includes the cookies as well as an extra data field. So my web.xml in App Engine looked like this:

<!-- Require user login for every access -->
<security-constraint>
    <web-resource-collection>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>*</role-name>
    </auth-constraint>
</security-constraint>

      

To access my application, the user must be authenticated, no matter what URL they are requesting. Since the RequestFactory is not authenticated, the server response from the html login page and the Android client throws a "Unable to parse payload" error. The strange thing is that you can send authenticated RPCs from the GWT side, and I don't understand why the developers of this API did it in such a way that the GWT side can send these authenticated calls, and the Android side is not able to send them.

What I have done now is that I have excluded the gwtRequest servlet from my security constraint with these extra lines in the web.xml file

<security-constraint>
        <web-resource-collection>
            <url-pattern>/gwtRequest</url-pattern>
        </web-resource-collection>
    </security-constraint>

      

I also noticed that if you are creating a new Android Engine related Android project that simply sets the required authentication in ProjectName.html.

+3


source share





All Articles