The OAuth protocol is dedicated to making Web sites and applications (collectively, consumer Consumer) able to access the protected resources of the user to the provider (service Provider) through the API without the user disclosing their authentication information. More generally, OAuth provides a freely implemented and universal method for API authentication. At present, many Internet services, such as Open API, have provided OAuth authentication Service, and OAuth Standard has gradually become the standard of open resource authorization. This article discusses how to use the OAuth Java library provided on Google Code to implement a OAuth-based Java application and, with Google's data Service, gives examples of accessing Google data using the OAuth approach.
OAuth Introduction
OAuth was co-sponsored by Blaine Cook, Chris Messina, Larry Halff and David Recordon to provide a safe and open standard for API access authorization.
Based on OAuth authentication authorization has the following characteristics:
Safety. OAuth differs from other licensing methods: OAuth authorization does not allow consumers (Consumer) to touch the user's account information (such as user name and password), but also means that consumers can apply for the authorization of the user's resources without using the user's username and password.
Open. Any consumer can use the OAuth Authentication Service, any service provider (Provider) can achieve its own OAuth certification services.
Simple. Both consumers and service providers are easy to understand and use.
The OAuth solution is shown in the following illustration.
Figure 1. OAuth Solution
As shown in Figure 1, the triangular relationship between users, consumers, and their service providers in the OAuth solution: When a user needs Consumer to provide a service for it, the service involves acquiring the user's protection resources from the service provider. OAuth Guarantee: Only if the user is explicitly authorized (step 4), the consumer can get the user's resources and use it to serve the user.