Accessing Google Services Using the OAuth 2.0 Protocol


The OAuth 2.0 protocol provides a simple and secure standard that allows third-party applications to access major service providers like Facebook, G+, and Twitter without compromising user passwords. The whole idea revolves around the existence of an access token, something like a unique key that can identify a user in place of a password. Access tokens are obtained by third-party applications after the user successfully authenticates with a web service. The whole process, known as authorization flow, begins when a user enters his credentials into a login window and finishes when the access token is acquired. The access token is usually refreshed from time to time. With this token, there is no need for any of the user’s personal data or password to be transmitted over the web each time that a client application asks for access on behalf of the user.


If you are not familiar with the OAuth 2.0 protocol you should do some background reading now before continuing this tutorial. Specifically, review the following links:



In general, the OAuth 2.0 authorization flow adheres to the following pattern:


  1. Let users connect to their online account.
  2. Get an authorization code (i.e. authorization token).
  3. Exchange the authorization code for an access token and a refresh token.
  4. Use the access token to interact with a web service or an API.
  5. Use the refresh token to update the access token when needed.


No comments:

Post a Comment