Skip to content

Test Android Application with own parse server #530

Description

@ofirattia

Hi,

I setup parse-server and its working fine with javascript sdk, however I am trying to check it via Android and I dont get any response.
for example this is an output from the console ( android studio )

D/ActivityThread: BDC-RECEIVER handled : 0 / ReceiverData{intent=Intent { act=com.google.android.c2dm.intent.REGISTRATION flg=0x10 pkg=com.transapp.user.transapp cmp=com.transapp.user.transapp/com.parse.PushService (has extras) } packageName=com.transapp.user.transapp resultCode=-1 resultData=null resultExtras=null}
02-20 15:52:44.044 21940-21980/com.transapp.user.transapp I/System.out: open:http://10.0.0.12:1337/parse/classes/Server
02-20 15:52:44.046 21940-21940/com.transapp.user.transapp D/ActivityThread: SVC-Creating service: CreateServiceData{token=android.os.BinderProxy@32bb808d className=com.parse.PushService packageName=com.transapp.user.transapp intent=null}
02-20 15:52:44.048 21940-21980/com.transapp.user.transapp D/libc-netbsd: [getaddrinfo]: hostname=10.0.0.12; servname=(null); cache_mode=(null), netid=0; mark=0
02-20 15:52:44.048 21940-21980/com.transapp.user.transapp D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
02-20 15:52:44.049 21940-21940/com.transapp.user.transapp D/ActivityThread: SVC-CREATE_SERVICE handled : 0 / CreateServiceData{token=android.os.BinderProxy@32bb808d className=com.parse.PushService packageName=com.transapp.user.transapp intent=null}
02-20 15:52:44.049 21940-21979/com.transapp.user.transapp I/System.out: open:http://10.0.0.12:1337/parse/classes/TestObject
02-20 15:52:44.050 21940-21940/com.transapp.user.transapp D/ActivityThread: SVC-Calling onStartCommand: com.parse.PushService@350ee242, flags=0, startId=1

Any suggestions? why its not working in Android?

Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
                .applicationId(YOUR_APPLICATION_ID)
                .clientKey(YOUR_CLIENT_KEY)
                .server("http://10.0.0.12:1337/parse/")   // '/' important after 'parse'
                .build());
        ParseObject testObject = new ParseObject("TestObject");
        testObject.put("foo", "bar");
        testObject.saveInBackground();

Activity

  1. ofirattia commented on Feb 20, 2016

    @ofirattia
    Author

    I added network interceptor and this is the log:

    /ParseLogInterceptor: Type : Request
    02-20 17:21:37.996 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Request-Id : 6
    02-20 17:21:37.996 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Url : http://10.0.0.12:1337/parse/classes/_User
    02-20 17:21:37.996 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Method : POST
    02-20 17:21:37.996 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Headers : {X-Parse-OS-Version=5.1, Content-Type=application/json, X-Parse-App-Build-Version=1, X-Parse-Client-Key=ll, X-Parse-Installation-Id=fee1d350-9544-4114-9584-bec74298cfd1, X-Parse-App-Display-Version=1.0, X-Parse-Client-Version=a1.13.0, Content-Length=60, User-Agent=Parse Android SDK 1.13.0 (com.transapp.user.transapp/1) API Level 22, X-Parse-Application-Id=Hkzc66hu0nsO3Q0yUMdh2h3zaa3Pdrtfv3fLRkwZ}
    02-20 17:21:37.996 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Body : {
    02-20 17:21:37.996 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor:     "email": "[email protected]",
    02-20 17:21:37.996 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor:     "username": "Ofg",
    02-20 17:21:37.996 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor:     "password": "1234567"
    02-20 17:21:37.996 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: }
    02-20 17:21:37.996 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: --------------
    02-20 17:21:38.026 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Type : Response
    02-20 17:21:38.027 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Request-Id : 6
    02-20 17:21:38.027 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Status-Code : 403
    02-20 17:21:38.027 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Reason-Phrase : Forbidden
    02-20 17:21:38.027 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Headers : {X-Android-Sent-Millis=1455981697999, Access-Control-Allow-Methods=GET,PUT,POST,DELETE,OPTIONS, X-Powered-By=Express, Date=Sat, 20 Feb 2016 15:21:42 GMT, Content-Length=24, X-Android-Response-Source=NETWORK 403, Connection=keep-alive, Access-Control-Allow-Headers=*, X-Android-Received-Millis=1455981698026, Access-Control-Allow-Origin=*}
    02-20 17:21:38.027 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: Body : Ignored
    02-20 17:21:38.027 2404-11049/com.transapp.user.transapp I/ParseLogInterceptor: --------------
    
  2. gfosco commented on Feb 20, 2016

    @gfosco
    Contributor

    Do you have any client keys configured in your ParseServer initialization? (rest api key, client key, javascript key, dot net key)... If you have any set, then all request require a valid match.. I would remove all of them and see if that's why you're getting a 403.

  3. ofirattia commented on Feb 20, 2016

    @ofirattia
    Author

    That`s why I get the 403. Thanks! so I there is need to define the keys , its recommended to define all the keys, right?

  4. gfosco commented on Feb 26, 2016

    @gfosco
    Contributor

    It's actually recommended to not set any client keys on the server. They don't add any security since they were public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions