In the past few weeks I’ve been developing a custom PHP login class that I will share with the rest of the devs in just a matter of days or weeks, depending on how quick I’ll move with what I’m about to ask next.
So my question would be, how would I make an Twitter login for my existing login app ?
As more info, I’m using a database to store the username, the hash of the password ( a complex algorithm I’ve been working on most of the time does that, so it’s pretty secure for now ), and the email address, also some other info that it’s not relevant in here.
That is why I ask, because I’ve seen some examples and tutorials on how this would work but none use a database. The thing is I need somehow to have the credentials stored in the same database ( with the new columns added as necessary ) and when the user want’s to login, the credentials would just be checked against the db instead of going to twitter again.
Also, only if the user is registered in my database, he could sign in with twitter, I’m not sure if this is possible.
Anyway, the main question is how would I create a Twitter login and use the database in the same time ?
Twitter used to use basic authentication, but now uses OAuth, so you wouldn’t be passing the password but having the user authorize your application via Twitter’s OAuth page. There are several tutorials and libraries out in the world to help you do this, or you can read Twitter’s documentation on implementing sign-in with Twitter.
What you’ll store in your database after authenticating is the user’s OAuth credentials (oauth token and secret) for future requests.