Tell me, please, how to log in to the system using a social network. I can not find any detailed information on how to do it correctly. There is a Java + Spring server (Tomcat) and an Android mobile application. The question is how to build an authorization mechanism? I can use the SDK from VK to authorize a user on a mobile device, yes, but what does it give me? How to authorize it in the system? Authorization in VC will give me some kind of token? Which I will send to my server, and the server should check the validity of this token using the same API from VK? Where can I read about it? Tell me how you solved such problems.

    1 answer 1

    There are several possible solutions. I would do something like this:

    1. On the mobile, the user is access_token in to the VC, getting access_token .
    2. Sends a token to the server.
    3. The server on the token gets the user profile with the VK API.
    4. Checks if there is such a user in the database by its id in the VC.
    5. If not, creates a user in his database, writing his id to the VC in the field of the user table.
    6. If the user already has one, or he has just been created, he generates his token for him by login (for example, id in VC) and password (even if it is a random string generated when creating the user)
    7. It sends the generated token to the mobile phone.
    8. Mobil writes it to SharedPreferences and uses it to query the server.

    As a result, for the user it will look like a login through VC, and you will have on the server all of his available info from VC, the ability to login the user by login and password and all requests to your server will nicely require a token.