
This article contains incorrect information about the 2Legged mode of the OAuth protocol. Thanks to all the people that commented on this article, I wrote a new article, where the 2Legged mode is (I hope) better explained and where a better client for OAuth is implemented. This article is left here for historical references and in order to keep the valuable comments that were added to it.
The OAuth protocol has two models that can be implemented. First, the 3legged model involves all the steps described by the RFC and it is generally used when the authentication of the user is involved in the process (this case is the most common). A very good example of implementing this form of the protocol is composed of the two applications (Sparklr and Tonr) that are delivered with the OAuth plugin for Spring Security source.
The second model is the 2legged model, where the second step of the process (the one where the user is presented with a login page from the server, and he/she needs to log in and then authorize the access to the protected resource) is skipped, on the reason that the client has an additional level of trust, and therefore it is sufficient the exchange and authorization of tokens (this is clearly incorrect; the 2Legged mode means that instead of having 3 parties involved, one has only 2: the provider and the consumer; read this for a better explanation), without the need for the user to authenticate itself.
In this article I will present how one can implement the server and the client for leveraging this flavor of the OAuth protocol. Read the rest of this entry »