vendredi 24 octobre 2014

Android authentication using JSON


Vote count:

0




I have a Python/Django server that is the API for a web service. I'm building an Android application that will communicate with the API and authenticate users, and enable them do all pulls/pushes from the server.


My trouble is with the particular communication with the server. Currently I use my WiFi network, and run the server like so python manage.py runserver 192.168.1.3:8000 so that it is available to any test device on my LAN.


The API is written so it returns http status messages with every response, so that I can tell the success or failure of a request before parsing the JSON reply.


On my Android side, I have used HttpURLConnection because it has the getHeaderField(null) method that I use to pick the http status message from the response. I get a status message 200 [success] when I 'ping' my server - this is a sort-of proof of concept.


My real issue is authentication. My API requires I send it a JSON with data, and it returns a JSON response [with an http status message in the head]. I can't seem to figure out how to do this. The JSON action I've seen around the interwebs are merely picking, or posting. I am wondering how I can POST and pick up a response from the server.


Extra information - Server supports HEAD and GET and OPTIONS. - Assuming server home is 192.168.1.3, user login/register would be in 192.168.1.3/user, events would be in 192.168.1.3/events and so on.. - This was the closest I got to figuring out a solution, but not quite..



asked 35 secs ago







Android authentication using JSON

Aucun commentaire:

Enregistrer un commentaire