E
E
Etmac2016-01-05 21:23:49
PHP
Etmac, 2016-01-05 21:23:49

How to properly authorize RESTful API?

In general, I am writing a RESTful API server and at first I fell into a stupor) The problem is user authorization, in theory this is what it should be: posting required fields -
first_name, last_name, country, city, gender, login_mode (vk (0) / fb (1)), secret_key (to confirm that this is our application sends data), social_id (data from the social network), then email,
if the user is in the database, we update the data and generate a new token, if not, then add and generate a token. So, I am writing exactly the server part, my friend is writing a client in java for android, that is, I don’t know at all what data he will send me, but in the end, how should I understand, I should send him something like a response in json format? How can I accurately send the data? I think something like this: {"first_name" : "Name", "last_name": "Surname" ... and so on}. Plus, if there is no user, I have to generate a token, should I also transfer the token to json? And on top of that, you need to send HTTP/1.1 201 created headers, as I understand it, using header() ? Of course, in this case, I swim, but only in practice, in theory, I understand how the client and server communicate. Friends, I hope for your practical advice, thanks in advance)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
seriogja, 2016-01-05
@seriogja

So, I am writing exactly the server part, my friend is writing a client in java for android, that is, I don’t know at all what data he will send me, but in the end, how should I understand, I should send him something like a response in json format? How can I accurately send the data?
You and your friend do not write functionality for someone else, but for yourself. You and him will find out what you need for the API to work, and he will tell you what he needs for the application. This will be the answer to the question of what and how to transmit!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question