It's not really possible to write it generically. To do something like FB login, you have to write code to call their APIs and handle the data they give back. It may be using OAuth2, but when calling the social graph, that's a Facebook-specific format.
There is a system in the code that might help, but for the most part you have to just deal with the API you want at the time.