Open ansgarm opened 9 years ago
Can you post your Android code where you hit this error please?
(The stacktrace I posted was from the Google AppEngine's error log)
I'm using exactly your example code..
// Get anonymous user
UserUtils.getAnonymousUser(this).toBlocking().first();
BackendObject object = new BackendObject();
object.put("comments", "This is awesome!");
BackendServices
.remote()
.save(object)
.subscribe();
Just my application differs..
public class FTApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Backend.init(new AndroidConfig(this, "https://xy.appspot.com/api/"));
}
}
With anonymous users, we first try logging in and if the user doesn't exist we create a new one then login again. So that log is actually expected the first time it is run. (We'll change this log to be more clear)
I'm assuming you've run this more than once though, so we need to figure out what's going on. Is it crashing client side?
Well it's not crashing on the client side (yay!). But here's the log from Retrofit:
Retrofit:<--- HTTP 200 https://xy.appspot.com/api/auth/key (7092ms)
Retrofit:: HTTP/1.1 200 OK
Retrofit:alternate-protocol: 443:quic,p=0.01
Retrofit:cache-control: private
Retrofit:content-type: application/json
Retrofit:date: Fri, 17 Oct 2014 17:45:27 GMT
Retrofit:OkHttp-Received-Millis: 1413567927461
Retrofit:OkHttp-Response-Source: NETWORK 200
Retrofit:OkHttp-Selected-Protocol: spdy/3.1
Retrofit:OkHttp-Sent-Millis: 1413567920689
Retrofit:server: Google Frontend
Retrofit:vary: Accept-Encoding
Retrofit:
Retrofit:[48,-126,1,34,48,13,6,9,42,-122,72,-122,-9,13,1,1,1,5,0,3,-126,1,15,0,48,-126,1,10,2,-126,1,1,0,-127,-128,-6,11,-24,12,-41,-96,114,-75,-113,-95,97,-85,52,57,51,-77,-43,-73,-6,85,13,-85,1,-82,104,-113,-66,-116,-51,-112,-16,94,110,116,82,30,-6,101,101,62,14,-122,-65,-85,-87,-36,-107,78,-60,-47,-35,115,84,-30,125,55,113,-35,33,-77,84,52,-3,-49,109,26,60,85,-39,-123,-2,-62,-92,-45,106,96,58,-14,74,6,-74,99,34,127,59,67,59,70,36,99,-45,-28,107,-118,-51,-91,15,-104,7,-109,-10,-96,-22,-23,27,77,-94,-111,-13,57,-35,-115,-12,23,16,29,-53,12,-12,117,-76,9,114,-82,-43,18,-93,125,23,5,21,80,7,55,-49,-114,-45,-66,69,-121,-25,-26,-3,-74,117,118,1,-7,-71,-78,-64,62,-126,101,110,29,56,4,77,-95,-114,32,-117,14,-53,-37,72,-19,112,87,-86,-100,35,48,80,-31,15,-123,-13,123,97,37,-62,113,92,-78,78,65,36,57,-62,-41,-91,35,-12,-58,-117,-2,-121,3,61,-125,100,-30,-127,16,-21,-113,62,17,-9,-90,-106,12,-11,79,16,70,106,48,-122,40,-50,22,82,-3,-4,20,-53,-35,-110,51,-21,-94,-33,-84,-122,35,-28,31,-89,114,98,109,-63,28,11,-19,65,125,54,48,61,51,2,3,1,0,1]
Retrofit:<--- END HTTP (1040-byte body)
Retrofit:---> HTTP PUT https://xy.appspot.com/api/auth
Retrofit:Content-Type: application/json; charset=UTF-8
Retrofit:Content-Length: 731
Retrofit:{"isEncrypted":true,"user_data":{},"meta_data":{"modified_date_key":"1413567927469","permissions_key":"{\"groups\":[],\"permissions\":{\"flags\":48}}","object_type":"io_divide_shared_transitory_Credentials","object_key":"c9f79495-20d2-4c91-9ed2-e14d5505aeb9","create_date_key":"1413567920361","email":"32c1c89587e14e48","pw":"AAABACoOdj4ddq6uFkzAXTSrQRaOsGVdp32lb8DRfUV2YJf04183cQNtx3SISNfjylpFpGX4MgeYjSXVJtoS_WNp9SiyGAhP6YiSA0f91-vftdv_A8JwzikmsH1U_e3jx0IeDWQmDJIuiXw98kGuLhU1qSzJYJnQvpiaq4GcdsGR7JEw0vcBDb5OfmEB5mxrBzMxocWUDZ7c5kdCF67f0At4QTeUr_3Cq3sOf9j-pcehm192KI2XeheRaTRxBptxE_OVS99O-__HosHNakNZvuG_7x-W87fa_k-RCKlNR6FwIqV5O5mpZgMYqSgQlFofqLP8cmV-1wqFZe4_-PUiXao7PI-8ZnTfxrjkg9Ske4fhdjH99gPJsSzqbrjdyWJ8uYDYXw\u003d\u003d"}}
Retrofit:---> END HTTP (731-byte body)
Retrofit:afterCall(/auth:PUT: 401 : null
Retrofit:<--- HTTP 401 https://xy.appspot.com/api/auth (816ms)
Retrofit:: HTTP/1.1 401 Unauthorized
Retrofit:alternate-protocol: 443:quic,p=0.01
Retrofit:cache-control: private
Retrofit:content-type: text/html; charset=utf-8
Retrofit:date: Fri, 17 Oct 2014 17:45:28 GMT
Retrofit:OkHttp-Received-Millis: 1413567928297
Retrofit:OkHttp-Response-Source: NETWORK 401
Retrofit:OkHttp-Selected-Protocol: spdy/3.1
Retrofit:OkHttp-Sent-Millis: 1413567927485
Retrofit:server: Google Frontend
Retrofit:vary: Accept-Encoding
Retrofit:
Retrofit:<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>401 Unauthorized</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Unauthorized</h1>
</body></html>
Retrofit:<--- END HTTP (200-byte body)
The .toBlocking()
call is synchronous and it appears it's not completing before the object save call.
Can you try running those calls in a separate thread?
Thread thread = new Thread()
{
@Override
public void run() {
try {
UserUtils.getAnonymousUser(context).toBlocking().first();
BackendObject object = new BackendObject();
object.put("comments", "This is awesome!");
BackendServices
.remote()
.save(object)
.subscribe();
} catch (Exception e) {
e.printStackTrace();
}
}
};
thread.start();
If this works for you, we'll update the Getting Started page.
Hey, I followed your server getting started and get the following Exception. Did I miss to include some library or something? (I try to login an anonymous user)