How is app login implemented by apps like facebook and amazon?

I am creating an Android app. For login and sign up, I am thinking to create a web service in python flask. When the user logs in his user Id will be returned by the service which he can use for retrieving data from the server.
I want to know how is this functionality implemented in apps like Facebook and Amazon keeping security in mind.