How to Write an OAuth Client to Access Data on Other Applications

307

oauth github authorize

Using OAuth, a developer can create an independent app that has access to its users’ accounts on other services. For example, Facebook lets developers create games whereby users of the games can post to their own walls on Facebook from within the app. The app doesn’t access the user’s credentials, thus keeping the interaction secure, and the user can at any time revoke the permissions granted to the app.

To accomplish this, Facebook and other services, including Google and GitHub, have implemented an OAuth service. There are two sets of code involved: The code running on the OAuth provider (e.g. Facebook itself), and the code running on the OAuth client (e.g. a site or app that lets you log in with your Facebook credentials). Between these two sets of code, programmers can write OAuth clients, e.g. websites and apps that let people log in using a provider such as Facebook. And that’s what we’re going to cover here.

How Does OAuth Work?